Submission #885131

#TimeUsernameProblemLanguageResultExecution timeMemory
885131votranngocvyDifference (POI11_roz)C++14
40 / 100
1065 ms65536 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int cnt[N][30]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) { char x; cin >> x; for (char j = 'a'; j <= 'z'; j++) cnt[i][j - 'a'] = cnt[i - 1][j - 'a']; cnt[i][x - 'a']++; } int ans = 0; for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) { int Min = 1e9 + 7,Max = 0; for (int k = 0; k < 26; k++) { Max = max(Max,cnt[j][k] - cnt[i - 1][k]); if (cnt[j][k] - cnt[i - 1][k] > 0) Min = min(Min,cnt[j][k] - cnt[i - 1][k]); } ans = max(ans,Max - Min); } cout << ans << "\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...
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...