# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1012454 | 2024-07-02T07:53:52 Z | Almonther | Difference (POI11_roz) | C++ | 682 ms | 25996 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[28]; void solve(){ cin>>n>>s; for(int i=0;i<n;i++) v[s[i]-'a'].push_back(i); for(int i=0;i<26;i++){ if(v[i].size()==0) continue; for(int j=0;j<26;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); } mx=max(mx,curr-mn); } } } co mx; } int main(){ suiii int tt=1; // cin>>tt; while(tt--){ solve(); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 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 | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 344 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 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 | 68 ms | 1880 KB | Output is correct |
2 | Incorrect | 0 ms | 344 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 623 ms | 14840 KB | Output is correct |
2 | Incorrect | 0 ms | 344 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 646 ms | 14836 KB | Output is correct |
2 | Correct | 391 ms | 13292 KB | Output is correct |
3 | Correct | 350 ms | 12124 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 682 ms | 14640 KB | Output is correct |
2 | Correct | 266 ms | 23464 KB | Output is correct |
3 | Incorrect | 263 ms | 13896 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 592 ms | 14908 KB | Output is correct |
2 | Correct | 208 ms | 25996 KB | Output is correct |
3 | Correct | 403 ms | 13676 KB | Output is correct |