Submission #721822

#TimeUsernameProblemLanguageResultExecution timeMemory
721822TimDeeElection (BOI18_election)C++17
28 / 100
3049 ms1324 KiB
// you're already the best // _ // ^ ^ // // >(O_O)<___// // \ __ __ \ // \\ \\ \\\\ #include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3","unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") using ll = long long; #define int long long //#define double long double #define forn(i,n) for(int i=0; i<(n); ++i) #define pb push_back #define pi pair<int,int> #define f first #define s second #define vii(a,n) vector<int> a(n); forn(i,n) cin>>a[i]; #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int inf = 1e18; const int mod = 998244353; const int N=7e4+3; bitset<N> a; void solve() { int n; cin>>n; string s; cin>>s; int m; cin>>m; forn(i,n) a[i]=s[i]=='C'; while (m--) { int l,r; cin>>l>>r; --l, --r; int ans=0; int s=0, x=0; for (int i=l; i<=r; ++i) { if (a[i]) { s++; if (x) --x; } else { if (!s) { ++ans; } else { --s, ++x; } } } cout<<ans+x<<'\n'; } } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; //cin>>t; while (t--) solve(); return 0; }

Compilation message (stderr)

election.cpp:5:1: warning: multi-line comment [-Wcomment]
    5 | //   \ __ __  \
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...