# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
169242 | 2019-12-19T08:20:09 Z | Ruxandra985 | Election (BOI18_election) | C++14 | 3000 ms | 1936 KB |
#include <bits/stdc++.h> using namespace std; int v[100010],w[100010]; int main() { FILE *fin = stdin; FILE *fout = stdout; int n, q , i , change , sum , l , r; char c; fscanf (fin,"%d\n",&n); for (i=1;i<=n;i++){ c=fgetc (fin); if (c == 'C') v[i] = 1; else v[i] = -1; w[i] = v[i]; } fscanf (fin,"%d",&q); for (;q;q--){ fscanf (fin,"%d%d",&l,&r); for (i=1;i<=n;i++) v[i] = w[i]; sum = 0; change = 0; for (i=l;i<=r;i++){ sum+=v[i]; if (sum<0){ v[i] = 0; sum++; change++; } } sum = 0; for (i=r;i>=l;i--){ sum+=v[i]; if (sum<0){ v[i] = 0; sum++; change++; } } fprintf (fout,"%d\n",change); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 7 ms | 376 KB | Output is correct |
3 | Correct | 6 ms | 376 KB | Output is correct |
4 | Correct | 8 ms | 376 KB | Output is correct |
5 | Correct | 7 ms | 504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 7 ms | 376 KB | Output is correct |
3 | Correct | 6 ms | 376 KB | Output is correct |
4 | Correct | 8 ms | 376 KB | Output is correct |
5 | Correct | 7 ms | 504 KB | Output is correct |
6 | Execution timed out | 3049 ms | 1936 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 7 ms | 376 KB | Output is correct |
3 | Correct | 6 ms | 376 KB | Output is correct |
4 | Correct | 8 ms | 376 KB | Output is correct |
5 | Correct | 7 ms | 504 KB | Output is correct |
6 | Execution timed out | 3049 ms | 1936 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |