Submission #871617

# Submission time Handle Problem Language Result Execution time Memory
871617 2023-11-11T07:51:10 Z vjudge1 Difference (POI11_roz) C++17
40 / 100
1000 ms 860 KB
#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

roz.cpp: In function 'void process()':
roz.cpp:25:13: warning: unused variable 'mx' [-Wunused-variable]
   25 |         int mx = 0;
      |             ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 285 ms 452 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1050 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 856 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -