답안 #1012458

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1012458 2024-07-02T07:58:45 Z Almonther Difference (POI11_roz) C++
30 / 100
739 ms 26464 KB
#include<bits/stdc++.h>

#define ll long long
#define co cout<<
#define suiii ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
// stuff
ll n;
string s;
ll mx=0;
vector<ll>v[100];
void solve(){
    cin>>n>>s;
    for(int i=0;i<n;i++) v[s[i]-'a'].push_back(i);
    for(int i=0;i<27;i++){
        if(v[i].size()==0) continue;
        for(int j=0;j<27;j++){
            ll l,r;
            l=r=0;
            vector<ll>arr;
            while(l!=v[i].size()||r!=v[j].size()){
                if(l==v[i].size()){
                    r++;
                    arr.push_back(-1);
                }
                else if(r==v[j].size()){
                    l++;
                    arr.push_back(1);
                }
                else if(v[i][l]<v[j][r]){
                    l++;
                    arr.push_back(1);
                }
                else{
                    r++;
                    arr.push_back(-1);
                }
            }
            ll curr=0;
            ll mn=1e18;
            for(auto k:arr){
                curr+=k;
                if(k==-1) mn=min(mn,curr);
                if(mn!=1e18) mx=max(mx,curr-mn);
            }
        }
    }
    
    co mx;
}

int main(){
    suiii
    int tt=1;
    // cin>>tt;
    while(tt--){
        solve();
    }
}

Compilation message

roz.cpp: In function 'void solve()':
roz.cpp:21:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |             while(l!=v[i].size()||r!=v[j].size()){
      |                   ~^~~~~~~~~~~~~
roz.cpp:21:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |             while(l!=v[i].size()||r!=v[j].size()){
      |                                   ~^~~~~~~~~~~~~
roz.cpp:22:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |                 if(l==v[i].size()){
      |                    ~^~~~~~~~~~~~~
roz.cpp:26:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |                 else if(r==v[j].size()){
      |                         ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 600 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 1628 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 700 ms 15240 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 696 ms 15096 KB Output is correct
2 Correct 467 ms 13304 KB Output is correct
3 Correct 383 ms 12148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 739 ms 14748 KB Output is correct
2 Correct 299 ms 23704 KB Output is correct
3 Incorrect 307 ms 14104 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 699 ms 15096 KB Output is correct
2 Correct 254 ms 26464 KB Output is correct
3 Correct 509 ms 13664 KB Output is correct