# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
871617 | vjudge1 | Difference (POI11_roz) | C++17 | 1078 ms | 860 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |