Submission #1110013

#TimeUsernameProblemLanguageResultExecution timeMemory
1110013quannnguyen2009JJOOII 2 (JOI20_ho_t2)C++17
100 / 100
36 ms5616 KiB
#pragma GCC optimize("O3,unroint-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include<bits/stdc++.h> #define int long long #define fi first #define se second #define pb push_back #define ii pair<int, int> #define sz(v) (int)v.size() #define aint(v) v.begin(), v.end() using namespace std; const int N=2e5+5, mod = 1e9+7, inf = 1e18; int n, k; string s; int co[N], cj[N], ci[N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k >> s; for (int i=0; i<n; i++) { co[i+1] = co[i]; cj[i+1] = cj[i]; ci[i+1] = ci[i]; if(s[i]=='O') co[i+1]++; else if(s[i]=='J') cj[i+1]++; else ci[i+1]++; } int mn = inf; for (int i=0; i<n; i++) { int cnt = 0; if(cj[i+1]<k) continue; int lo=0, hi=i+1; while(lo+1<hi) { int mid = (lo+hi)>>1; if(cj[i+1]-cj[mid]>=k) lo = mid; else hi = mid; } cnt+=i-lo+1-k; lo=i; hi=n; while(lo+1<hi) { int mid = (lo+hi)>>1; if(co[mid]-co[i]>=k) hi = mid; else lo = mid; } cnt += hi-i-1-k; int nl = hi; if(ci[n]-ci[hi]<k) continue; lo = nl; hi = n; while(lo+1<hi) { int mid = (lo+hi)>>1; if(ci[mid]-ci[nl]<k) lo=mid; else hi = mid; } cnt += hi-nl-k; mn = min(mn, max(cnt, 0LL)); } if(mn==inf) cout << -1; else cout << mn; }

Compilation message (stderr)

ho_t2.cpp:1:40: warning: bad option '-funroint-loops' to pragma 'optimize' [-Wpragmas]
    1 | #pragma GCC optimize("O3,unroint-loops")
      |                                        ^
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
    2 | #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
      |                                                ^
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-loops' to attribute 'optimize' [-Wattributes]
ho_t2.cpp:2:48: warning: bad option '-funroint-
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...