Submission #871617

#TimeUsernameProblemLanguageResultExecution timeMemory
871617vjudge1Difference (POI11_roz)C++17
40 / 100
1078 ms860 KiB
#include <bits/stdc++.h> #define fi first #define se second using namespace std; const int maxn = 2e5+55; typedef pair <int,int> pii; char a[maxn]; int cnt[maxn]; void process() { int n; cin >> n; for (int i = 1; i <= n; i ++) cin >> a[i]; int best = 0; for (int i = 1; i <= n; i ++) { multiset <int> st; for (int c = 0; c < 26; c ++) cnt[c] = 0; int mx = 0; for (int j = i; j <= n; j ++) { int c = a[j] - 'a'; if (st.find(cnt[c]) != st.end()) st.erase(st.find(cnt[c])); cnt[c] ++; st.insert(cnt[c]); int delta = abs(*(st.begin()) - *(--st.end())); best = max(best, delta); // cout << i << " " << j << " " << delta << endl; } } cout << best; } signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int ntest = 1; while (ntest --) process(); return 0; }

Compilation message (stderr)

roz.cpp: In function 'void process()':
roz.cpp:25:13: warning: unused variable 'mx' [-Wunused-variable]
   25 |         int mx = 0;
      |             ^~
#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...