# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1102507 | 2024-10-18T08:10:17 Z | LTTrungCHL | Election (BOI18_election) | C++17 | 5 ms | 1108 KB |
///***LTT***/// /// ->NHAT QUOC GIA<- /// #include<bits/stdc++.h> //#pragma GCC optimize ("O3") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("popcnt") //#define int long long #define endl "\n" #define F first #define S second #define pb push_back using namespace std; vector <int> lg2; //void MAKE_LOG_ARR(int n){ // lg2.resize(n + 3); // for (int i = 1;i <= n;++i){ // lg2[i] = __lg(i); // } //} const long long oo = 1e9+7; const int N = 5 * 1e5 + 10; int n, q, a[N]; string s; namespace sub1{ int pre[2002], sur[2002], b[2002]; void solve(){ while (q--){ int l, r; cin >> l >> r; for (int i = l;i <= r;++i){ b[i] = a[i]; } int ans = 0; for (int i = l;i <= r;++i){ pre[i] = (i == l ? 0 : pre[i - 1] ) + b[i]; if (pre[i] < 0){ b[i] = 0; ++ans; ++pre[i]; } } for (int i = r;i >= l;--i){ sur[i] = (i == r ? 0 : sur[i + 1] ) + b[i]; if (sur[i] < 0){ b[i] = 0; ++ans; ++sur[i]; } } cout << ans <<"\n"; } return; } }; void solve(){ cin >> n; cin >> s; for (int i = 0;i < s.size();++i){ if (s[i] == 'T'){ a[i + 1] = -1; } else a[i + 1] = 1; } cin >> q; if (n <= 2000 and q <= 2000){ sub1::solve(); return; } return; } int main(){ ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); if (fopen("ltt.inp", "r")){ freopen("ltt.inp", "r", stdin); freopen("ltt.out", "w", stdout); } // int t; // cin >> t; // while(t--){ solve(); // } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 340 KB | Output is correct |
2 | Correct | 4 ms | 340 KB | Output is correct |
3 | Correct | 4 ms | 340 KB | Output is correct |
4 | Correct | 5 ms | 340 KB | Output is correct |
5 | Correct | 4 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 340 KB | Output is correct |
2 | Correct | 4 ms | 340 KB | Output is correct |
3 | Correct | 4 ms | 340 KB | Output is correct |
4 | Correct | 5 ms | 340 KB | Output is correct |
5 | Correct | 4 ms | 340 KB | Output is correct |
6 | Incorrect | 1 ms | 1108 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 340 KB | Output is correct |
2 | Correct | 4 ms | 340 KB | Output is correct |
3 | Correct | 4 ms | 340 KB | Output is correct |
4 | Correct | 5 ms | 340 KB | Output is correct |
5 | Correct | 4 ms | 340 KB | Output is correct |
6 | Incorrect | 1 ms | 1108 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |