# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1002674 | 2024-06-19T17:49:38 Z | Andrey | Election (BOI18_election) | C++14 | 3000 ms | 2176 KB |
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); int n,q,l,r; cin >> n; string s; cin >> s; vector<int> haha(n+1); cin >> q; for(int i = 1; i <= n; i++) { if(s[i-1] == 'C') { haha[i] = 1; } else { haha[i] = -1; } } for(int i = 0; i < q; i++) { cin >> l >> r; vector<int> bruh(r-l+1); for(int j = l; j <= r; j++) { bruh[j-l] = haha[j]; } int ans = 0,br = 0; for(int j = 0; j < bruh.size(); j++) { br+=bruh[j]; if(br < 0) { br++; bruh[j] = 0; ans++; } } br = 0; for(int j = bruh.size()-1; j >= 0; j--) { br+=bruh[j]; if(br < 0) { br++; bruh[j] = 0; ans++; } } cout << ans << "\n"; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 348 KB | Output is correct |
2 | Correct | 3 ms | 348 KB | Output is correct |
3 | Correct | 3 ms | 344 KB | Output is correct |
4 | Correct | 3 ms | 348 KB | Output is correct |
5 | Correct | 5 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 348 KB | Output is correct |
2 | Correct | 3 ms | 348 KB | Output is correct |
3 | Correct | 3 ms | 344 KB | Output is correct |
4 | Correct | 3 ms | 348 KB | Output is correct |
5 | Correct | 5 ms | 344 KB | Output is correct |
6 | Correct | 2422 ms | 2176 KB | Output is correct |
7 | Execution timed out | 3044 ms | 1688 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 348 KB | Output is correct |
2 | Correct | 3 ms | 348 KB | Output is correct |
3 | Correct | 3 ms | 344 KB | Output is correct |
4 | Correct | 3 ms | 348 KB | Output is correct |
5 | Correct | 5 ms | 344 KB | Output is correct |
6 | Correct | 2422 ms | 2176 KB | Output is correct |
7 | Execution timed out | 3044 ms | 1688 KB | Time limit exceeded |
8 | Halted | 0 ms | 0 KB | - |