# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
61693 | 2018-07-26T10:44:55 Z | hamzqq9 | Election (BOI18_election) | C++14 | 21 ms | 656 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long #define inf 1000000000000000000 #define umax(x,y) x=max(x,(y)) #define pw(x) (1<<(x)) char s[2234],temp[2234]; int n,q,x,y; int main() { // freopen("in.txt","r",stdin); scanf("%d",&n); scanf("%s",s+1); scanf("%d",&q); while(q--) { scanf("%d %d",&x,&y); for(int i=x;i<=y;i++) { temp[i]=s[i]; } int bas=x,son=y; int sumx=0,sumy=0; int ans=0; while(x<=son && y>=bas) { sumx+=(temp[x]=='T'?-1:temp[x]=='C'?1:0); if(sumx<0) { ans++; sumx++; if(x>y) sumy++; temp[x]='0'; } x++; sumy+=(temp[y]=='T'?-1:temp[y]=='C'?1:0); if(sumy<0) { ans++; sumy++; if(y<x) sumx++; temp[y]='0'; } y--; } printf("%d\n",ans); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 376 KB | Output is correct |
2 | Correct | 20 ms | 488 KB | Output is correct |
3 | Correct | 19 ms | 524 KB | Output is correct |
4 | Correct | 20 ms | 524 KB | Output is correct |
5 | Correct | 8 ms | 524 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 21 ms | 376 KB | Output is correct |
2 | Correct | 20 ms | 488 KB | Output is correct |
3 | Correct | 19 ms | 524 KB | Output is correct |
4 | Correct | 20 ms | 524 KB | Output is correct |
5 | Correct | 8 ms | 524 KB | Output is correct |
6 | Runtime error | 3 ms | 656 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 | 21 ms | 376 KB | Output is correct |
2 | Correct | 20 ms | 488 KB | Output is correct |
3 | Correct | 19 ms | 524 KB | Output is correct |
4 | Correct | 20 ms | 524 KB | Output is correct |
5 | Correct | 8 ms | 524 KB | Output is correct |
6 | Runtime error | 3 ms | 656 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
7 | Halted | 0 ms | 0 KB | - |