답안 #44398

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
44398 2018-04-01T22:54:03 Z imaxblue Difference (POI11_roz) C++17
100 / 100
764 ms 26080 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() ((rand() << 14)+rand())
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846

int n, k, c, c2, ans;
char ch;
pii sw[1000005];
vector<pii> v[30];
int main(){
    cin >> n;
    fox(l, n){
        cin >> ch;
        v[ch-'a'].pb(mp(l, ch-'a'));
    }
    fox(l, 26){
        fox(l2, 26){
            merge(v[l].begin(), v[l].end(), v[l2].begin(), v[l2].end(), sw);
            k=v[l].size()+v[l2].size();
            c2=-(1<<30); c=0;
            fox(l3, k){
                if (sw[l3].y==l){
                    c++;
                    c2++;
                } else {
                    c2=c-1;
                    c=max(0, c-1);
                }
                ans=max(ans, c2);
            }
        }
    }
    cout << ans;
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 584 KB Output is correct
2 Correct 2 ms 588 KB Output is correct
3 Correct 2 ms 612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 612 KB Output is correct
2 Correct 2 ms 612 KB Output is correct
3 Correct 2 ms 660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 716 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 760 KB Output is correct
2 Correct 2 ms 776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 1932 KB Output is correct
2 Correct 2 ms 1932 KB Output is correct
3 Correct 6 ms 1932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 728 ms 11116 KB Output is correct
2 Correct 2 ms 11116 KB Output is correct
3 Correct 491 ms 11116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 758 ms 12936 KB Output is correct
2 Correct 550 ms 12936 KB Output is correct
3 Correct 187 ms 13360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 732 ms 15624 KB Output is correct
2 Correct 252 ms 20492 KB Output is correct
3 Correct 216 ms 20492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 764 ms 20492 KB Output is correct
2 Correct 230 ms 26080 KB Output is correct
3 Correct 210 ms 26080 KB Output is correct