답안 #885127

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
885127 2023-12-09T03:12:16 Z vjudge1 Difference (POI11_roz) C++17
100 / 100
75 ms 1528 KB
#include<bits/stdc++.h>
using namespace std;
const int N=26;
int res=0, n;
int pre[N][N], premin[N][N], last[N][N];
string s;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>s;
    for(int i=0; i<N; i++)
        for(int j=0; j<N; j++) premin[i][j]=1e9;
    for(int i=0; i<n; i++)
    {
        int a=s[i]-'a';
        for(int b=0; b<N; b++)
            if(a!=b)
            {
                pre[a][b]++;
                res=max(res, pre[a][b]-premin[a][b]);
                premin[b][a]=min(premin[b][a], last[b][a]);
                last[b][a]=--pre[b][a];
                res=max(res, pre[b][a]-premin[b][a]);
            }
    }
    cout<<res;
    return 0;
}
# 결과 실행 시간 메모리 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 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 1524 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 71 ms 1520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 1528 KB Output is correct
2 Correct 58 ms 1516 KB Output is correct
3 Correct 56 ms 1520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 1524 KB Output is correct
2 Correct 66 ms 1528 KB Output is correct
3 Correct 58 ms 1524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 1528 KB Output is correct
2 Correct 66 ms 1528 KB Output is correct
3 Correct 61 ms 1528 KB Output is correct