#include <bits/stdc++.h>
using namespace std;
const int Nmax=310, INF=1e9;
int S, Q, D[Nmax][Nmax][Nmax];
bool visited[Nmax][Nmax][Nmax];
int F(int a, int b, int d) {
if(a<=0) return INF;
if(visited[a][b][d]) return D[a][b][d];
visited[a][b][d]=true;
for(int s=1, e=300; s<=e; ) {
int c=(s+e)/2;
if((d>=1 && F(c, d-1, b)<a) || F(c-max(0, a-d*S), d, b)<a) D[a][b][d]=c, s=c+1;
else e=c-1;
}
return D[a][b][d];
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>S>>Q;
while(Q--) {
int ch, fh, cg, fg;
cin>>ch>>fh>>cg>>fg;
if(F(ch, fh, fg)<cg) cout<<"YES\n";
else cout<<"NO\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
16988 KB |
Output is correct |
2 |
Runtime error |
2 ms |
348 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
16988 KB |
Output is correct |
2 |
Incorrect |
66 ms |
92344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
16988 KB |
Output is correct |
2 |
Incorrect |
66 ms |
92344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
16988 KB |
Output is correct |
2 |
Incorrect |
66 ms |
92344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
16988 KB |
Output is correct |
2 |
Incorrect |
66 ms |
92344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
16988 KB |
Output is correct |
2 |
Incorrect |
66 ms |
92344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
16988 KB |
Output is correct |
2 |
Incorrect |
66 ms |
92344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |