Submission #582095

#TimeUsernameProblemLanguageResultExecution timeMemory
582095amunduzbaevBoarding Passes (BOI22_passes)C++17
0 / 100
1 ms340 KiB
#include "bits/stdc++.h" using namespace std; #define ar array typedef int64_t ll; #define int ll const int N = 1e5 + 5; int pref[N], suff[N]; signed main(){ ios::sync_with_stdio(0); cin.tie(0); string s; cin>>s; int n = s.size(); for(int i=0;i<n;i++){ if(i) pref[i] += pref[i-1]; pref[i] += i; } for(int i=n-1;~i;i--){ suff[i] += suff[i+1]; suff[i] += (n - i - 1); } int res = pref[n-1]; for(int i=1;i<n;i++){ res = min(res, pref[i-1] + suff[i]); } cout<<res / 2.<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...