# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
63522 | 2018-08-02T05:17:49 Z | Just_Solve_The_Problem | Election (BOI18_election) | C++11 | 35 ms | 1124 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = (int)2e3 + 7; int used[N]; main() { int n; string s; scanf("%d", &n); cin >> s; s = " " + s; int q; scanf("%d", &q); while (q--) { int l, r; int ans = 0; scanf("%d %d", &l, &r); int b = 0; for (int i = l; i <= r; i++) { b += ((s[i] == 'T') ? -1 : 1); if (b < 0) { used[i] = 1; ans++; b++; } } b = 0; for (int i = r; i >= l; i--) { if (used[i]) { used[i] = 0; continue; } b += ((s[i] == 'T') ? -1 : 1); if (b < 0) { ans++; b++; } } printf("%d\n", ans); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 376 KB | Output is correct |
2 | Correct | 8 ms | 460 KB | Output is correct |
3 | Correct | 7 ms | 460 KB | Output is correct |
4 | Correct | 8 ms | 460 KB | Output is correct |
5 | Correct | 6 ms | 544 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 376 KB | Output is correct |
2 | Correct | 8 ms | 460 KB | Output is correct |
3 | Correct | 7 ms | 460 KB | Output is correct |
4 | Correct | 8 ms | 460 KB | Output is correct |
5 | Correct | 6 ms | 544 KB | Output is correct |
6 | Runtime error | 5 ms | 1124 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 376 KB | Output is correct |
2 | Correct | 8 ms | 460 KB | Output is correct |
3 | Correct | 7 ms | 460 KB | Output is correct |
4 | Correct | 8 ms | 460 KB | Output is correct |
5 | Correct | 6 ms | 544 KB | Output is correct |
6 | Runtime error | 5 ms | 1124 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
7 | Halted | 0 ms | 0 KB | - |