#include <bits/stdc++.h>
using namespace std;
const int MAXN = 4005;
const int INF = 1 << 31;
char b[MAXN];
int t[MAXN];
int tc[MAXN];
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int N, Vm, V2;
cin >> N >> Vm >> V2;
for(int i = 0; i < N; i++) cin >> b[i] >> t[i];
for(int i = N - 1; i > 0; i--) t[i] -= t[i - 1];
//for(int i = 0; i < N; i++) printf("%d ", t[i]);
//printf("\n");
tc[0] = INF;
for(int i = 1; i < N; i++) tc[i] = t[i] - 1;
sort(tc, tc + N);
for(int i = N - 1; i >= 0; i--) {
int s = V2, e = V2;
bool ava = true;
for(int j = N - 1; j > 0; j--) if(t[j] <= tc[i]) {
if(b[j] == '+') {
s = max(0, s - 1);
e = e == Vm ? Vm : e - 1;
}
else {
s = s == 0 ? 0 : s + 1;
e = min(Vm, e + 1);
}
if(s > e) {
ava = false;
break;
}
}
if(ava) {
if(i == N - 1) cout << "infinity";
else cout << tc[i] << " " << e;
return 0;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
380 KB |
Output is correct |
2 |
Correct |
11 ms |
376 KB |
Output is correct |
3 |
Correct |
15 ms |
404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
376 KB |
Output is correct |
2 |
Correct |
22 ms |
376 KB |
Output is correct |
3 |
Correct |
19 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
556 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |