답안 #77224

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
77224 2018-09-24T06:39:26 Z farukkastamonuda Difference (POI11_roz) C++14
100 / 100
717 ms 25936 KB
#include <bits/stdc++.h>
#define li 1000005
#define fi first
#define se second
#define mp make_pair
using namespace std;
int n,c,c2,ans;
char s[li],ch;
vector< pair<int,int> > v[35];
pair<int,int> sw[li];
int main(){
    scanf("%d",&n);
    //scanf("%s",s+1);
    for(int i=1;i<=n;i++){
        scanf(" %c",&ch);
        v[ch-'a'].push_back(mp(i,ch-'a'));
    }
    for(int i=0;i<26;i++){
        for(int j=0;j<26;j++){
            merge(v[i].begin(),v[i].end(),v[j].begin(),v[j].end(),sw);
            int gh=(int)v[i].size()+(int)v[j].size();
            c2=-(1<<30);c=0;
            for(int k=0;k<gh;k++){
                if(sw[k].se==i){
                    c++;
                    c2++;
                }
                else{
                    c2=c-1;
                    c--;
                    c=max(0,c);
                }
                ans=max(ans,c2);
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Compilation message

roz.cpp: In function 'int main()':
roz.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
roz.cpp:15: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 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 564 KB Output is correct
3 Correct 2 ms 628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 668 KB Output is correct
2 Correct 2 ms 700 KB Output is correct
3 Correct 2 ms 704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 708 KB Output is correct
2 Correct 2 ms 712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 732 KB Output is correct
2 Correct 2 ms 872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 1948 KB Output is correct
2 Correct 2 ms 1948 KB Output is correct
3 Correct 5 ms 1948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 679 ms 10992 KB Output is correct
2 Correct 2 ms 10992 KB Output is correct
3 Correct 387 ms 10992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 678 ms 12884 KB Output is correct
2 Correct 536 ms 12884 KB Output is correct
3 Correct 165 ms 13316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 698 ms 15656 KB Output is correct
2 Correct 274 ms 20484 KB Output is correct
3 Correct 180 ms 20484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 717 ms 20484 KB Output is correct
2 Correct 206 ms 25936 KB Output is correct
3 Correct 193 ms 25936 KB Output is correct