답안 #85708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
85708 2018-11-21T11:42:01 Z memetkagan44 Difference (POI11_roz) C++11
100 / 100
735 ms 26272 KB
#include<bits/stdc++.h>
using namespace std;
int n,ans;
char a;
vector<pair<int,int> > v[28];
pair<int,int> temp[1000005];
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf(" %c",&a);
        v[a-'a'].push_back(make_pair(i,a-'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(),temp);
            int cnt=0,cnt2=(-1)*(0x3f3f3f3f);
            for(int q=0;q<v[i].size()+v[j].size();q++){
                if(temp[q].second==i){
                    cnt2++;
                    cnt++;
                }
                else{
                    cnt--;
                    cnt2=cnt;
                    cnt=max(0,cnt);
                }
                ans=max(ans,cnt2);
            }
        }
    printf("%d\n",ans);
    return 0;
}

Compilation message

roz.cpp: In function 'int main()':
roz.cpp:17:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int q=0;q<v[i].size()+v[j].size();q++){
                         ~^~~~~~~~~~~~~~~~~~~~~~~~
roz.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
roz.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf(" %c",&a);
         ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
3 Correct 3 ms 652 KB Output is correct
4 Correct 2 ms 688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 688 KB Output is correct
2 Correct 2 ms 804 KB Output is correct
3 Correct 2 ms 932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 932 KB Output is correct
2 Correct 2 ms 932 KB Output is correct
3 Correct 2 ms 964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 964 KB Output is correct
2 Correct 2 ms 964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 980 KB Output is correct
2 Correct 2 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 2020 KB Output is correct
2 Correct 2 ms 2020 KB Output is correct
3 Correct 6 ms 2020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 735 ms 11140 KB Output is correct
2 Correct 2 ms 11140 KB Output is correct
3 Correct 388 ms 11140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 732 ms 13268 KB Output is correct
2 Correct 513 ms 13268 KB Output is correct
3 Correct 160 ms 13464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 709 ms 15900 KB Output is correct
2 Correct 232 ms 20596 KB Output is correct
3 Correct 194 ms 20596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 717 ms 20596 KB Output is correct
2 Correct 218 ms 26272 KB Output is correct
3 Correct 204 ms 26272 KB Output is correct