Submission #844396

#TimeUsernameProblemLanguageResultExecution timeMemory
844396vjudge1Nivelle (COCI20_nivelle)C++17
38 / 110
15 ms2136 KiB
#include <bits/stdc++.h> using namespace std; #define int long long void solve(){ string str = "abcde"; int k = 5; int n;cin >> n; int arr[n],cur[n]; for(int i = 0;i<n;i++){ char ch;cin >> ch; arr[i] = ch - 'a'; } memset(cur , 0 , sizeof(cur)); int pay = 1 , payda = 0 , l = 1 , r = 1; for(int bit = 0;bit < (1 << k);bit++){ for(int j = 0;j<n;j++){ cur[j] = (bit >> arr[j]) & 1; } int mx = 0 , sayac = 0 , templ = 1 , tempr = 1; for(int i = 0;i<=n;i++){ if(i != n and cur[i] == 1){ sayac++; } else{ if(mx < sayac){ mx = sayac; templ = i - sayac + 1; tempr = i; } sayac = 0; } } if(pay * mx > ((int)__builtin_popcount(bit)) * payda){ pay = ((int)__builtin_popcount(bit)); payda = mx; l = templ; r = tempr; } } cout << l << " " << r << endl; } signed main(){ ios_base::sync_with_stdio(0);cin.tie(0); int testcase = 1;//cin >> testcase; while(testcase--)solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...