# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
480835 | 2021-10-18T10:22:16 Z | Karabasan | Election (BOI18_election) | C++17 | 3000 ms | 940 KB |
#include <bits/stdc++.h> #define ll long long #define fast1 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; #pragma GCC optimize("Ofast") #pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4") #pragma GCC optimize("unroll-loops") int n,t,m; int pre[500005]; void solve() { string AAA; string s="G"; cin>>n; cin>>AAA; s+=AAA; int q; scanf("%d",&q); while(q--) { string u=s; int a,b; cin>>a>>b; int c=0; int t=0; int mx=0; for(int i=a;i<=b;i++) { if(u[i]=='T') c++; else c--; if(c>0) { u[i]='U'; c=0; mx++; } } int mx2=0; for(int i=b;i>=a;i--) { if(u[i]=='T') t++; else if(u[i]=='C') t--; mx2=max(mx2,t); } mx+=mx2; cout<<mx<<endl; } } int main() { // scanf("%d",&t); t=1; while(t--) { solve(); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 204 KB | Output is correct |
2 | Correct | 21 ms | 336 KB | Output is correct |
3 | Correct | 20 ms | 332 KB | Output is correct |
4 | Correct | 21 ms | 332 KB | Output is correct |
5 | Correct | 14 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 204 KB | Output is correct |
2 | Correct | 21 ms | 336 KB | Output is correct |
3 | Correct | 20 ms | 332 KB | Output is correct |
4 | Correct | 21 ms | 332 KB | Output is correct |
5 | Correct | 14 ms | 332 KB | Output is correct |
6 | Execution timed out | 3057 ms | 940 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 204 KB | Output is correct |
2 | Correct | 21 ms | 336 KB | Output is correct |
3 | Correct | 20 ms | 332 KB | Output is correct |
4 | Correct | 21 ms | 332 KB | Output is correct |
5 | Correct | 14 ms | 332 KB | Output is correct |
6 | Execution timed out | 3057 ms | 940 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |