# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
60920 | 2018-07-25T01:39:20 Z | ksun48 | Election (BOI18_election) | C++14 | 3000 ms | 1384 KB |
#include <bits/stdc++.h> using namespace std; typedef long long LL; int n; int q; string s; vector<int> psums; int max_psum(int a, int b){ int z = 0; for(int i = a; i <= b; i++){ for(int j = i; j <= b; j++){ z = max(psums[j] - psums[i], z); } } return z; } int main(){ cin.sync_with_stdio(0); cin.tie(0); cin >> n >> s >> q; psums.push_back(0); for(int i = 0; i < s.size(); i++){ if(s[i] == 'C'){ psums.push_back(psums[psums.size() - 1] + 1); } else { psums.push_back(psums[psums.size() - 1] - 1); } } for(int i = 0; i < q; i++){ int l, r; cin >> l >> r; l--; r--; r++; int a = max_psum(l, r); cout << a - (psums[r] - psums[l]) << '\n'; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 447 ms | 388 KB | Output is correct |
2 | Correct | 453 ms | 484 KB | Output is correct |
3 | Correct | 466 ms | 560 KB | Output is correct |
4 | Correct | 470 ms | 660 KB | Output is correct |
5 | Correct | 501 ms | 660 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 447 ms | 388 KB | Output is correct |
2 | Correct | 453 ms | 484 KB | Output is correct |
3 | Correct | 466 ms | 560 KB | Output is correct |
4 | Correct | 470 ms | 660 KB | Output is correct |
5 | Correct | 501 ms | 660 KB | Output is correct |
6 | Execution timed out | 3040 ms | 1384 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 447 ms | 388 KB | Output is correct |
2 | Correct | 453 ms | 484 KB | Output is correct |
3 | Correct | 466 ms | 560 KB | Output is correct |
4 | Correct | 470 ms | 660 KB | Output is correct |
5 | Correct | 501 ms | 660 KB | Output is correct |
6 | Execution timed out | 3040 ms | 1384 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |