답안 #44399

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
44399 2018-04-01T22:54:57 Z imaxblue Difference (POI11_roz) C++17
100 / 100
825 ms 16384 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(){
    scan(n);
    fox(l, n){
        scanf(" %c", &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;
}

Compilation message

roz.cpp: In function 'int main()':
roz.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c", &ch);
         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 544 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 564 KB Output is correct
2 Correct 2 ms 564 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 564 KB Output is correct
2 Correct 2 ms 564 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 612 KB Output is correct
2 Correct 2 ms 612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 612 KB Output is correct
2 Correct 2 ms 612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 1636 KB Output is correct
2 Correct 2 ms 1636 KB Output is correct
3 Correct 6 ms 1636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 710 ms 9788 KB Output is correct
2 Correct 2 ms 9788 KB Output is correct
3 Correct 487 ms 9788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 825 ms 9904 KB Output is correct
2 Correct 566 ms 9904 KB Output is correct
3 Correct 211 ms 9904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 729 ms 9904 KB Output is correct
2 Correct 246 ms 13724 KB Output is correct
3 Correct 225 ms 13724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 741 ms 13724 KB Output is correct
2 Correct 224 ms 16384 KB Output is correct
3 Correct 235 ms 16384 KB Output is correct