import java
.util
.Scanner
;
public class S7_09 {
static int n
,s
,m
,num
;
static String
[] rec
= new String[55];
static int[] piao
= new int[55];
static int a
,b
;
public static void main(String
[] args
) {
Scanner sc
= new Scanner(System
.in
);
n
= sc
.nextInt();
m
= sc
.nextInt();
for (int i
= 1; i
< n
; i
++) {
piao
[i
] = m
;
}
for (int i
= 0; i
< n
; i
++) {
rec
[i
] = sc
.next();
}
m
= sc
.nextInt();
for (int i
= 0; i
< m
; i
++) {
a
= getNum(sc
.next());
b
= getNum(sc
.next());
num
= sc
.nextInt();
f();
}
}
static void f() {
int max
= 1000;
for (int j
= a
+ 1; j
<= b
; j
++) {
max
= Math
.min(max
,piao
[j
]);
}
System
.out
.print(max
+ " ");
if (num
<= max
) {
System
.out
.println("YES");
for (int j
= a
+ 1; j
<=b
; j
++) {
piao
[j
] -= num
;
}
} else {
System
.out
.println("NO");
}
}
static int getNum(String str
) {
for (int i
= 0; i
< 55; i
++) {
if (str
.equals(rec
[i
])) return i
;
}
return -1;
}
}
#include<iostream>
#include<map>
#include<string>
using namespace std
;
int arr
[55];
int main(){
int n
,s
,m
,count
,x
,y
,Min
;
string str
,strbegin
,strend
;
map
<string
,int>mapCar
;
cin
>>n
>>s
;
for(int i
=0;i
<n
;i
++){
cin
>>str
;
arr
[i
]=s
;
mapCar
.insert(pair
<string
,int>(str
,i
));
}
map
<string
,int>::iterator iter1
;
map
<string
,int>::iterator iter2
;
cin
>>m
;
for(int i
=0;i
<m
;i
++){
Min
=205;
cin
>>strbegin
>>strend
>>count
;
iter1
=mapCar
.find(strbegin
);
iter2
=mapCar
.find(strend
);
x
=iter1
->second
;
y
=iter2
->second
;
for(int j
=x
;j
<=y
-1;j
++){
if(Min
>arr
[j
]){
Min
=arr
[j
];
}
}
if(Min
>=count
){
cout
<<Min
<<' '<<"YES"<<endl
;
for(int j
=x
;j
<=y
-1;j
++){
arr
[j
]=arr
[j
]-count
;
}
}
else cout
<<Min
<<' '<<"NO"<<endl
;
}
return 0;
}
转载请注明原文地址: https://win8.8miu.com/read-11489.html