# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1012460 | 2024-07-02T08:03:35 Z | Almonther | Difference (POI11_roz) | C++ | 1000 ms | 34092 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; vector<ll>pref; 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; pref.push_back(curr); } for(int i=0;i<pref.size();i++){ if(i==0){ if(pref[i]==-1){ mn=min(mn,pref[i]); } } else if(pref[i]<pref[i-1]) mn=min(mn,pref[i]); mx=max(mx,pref[i]-mn); } } } co mx; } int main(){ suiii int tt=1; // cin>>tt; while(tt--){ solve(); } }
Compilation message
# | Verdict | Execution time | Memory | 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 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | 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 | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 70 ms | 1764 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 937 ms | 15892 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 937 ms | 15888 KB | Output is correct |
2 | Correct | 614 ms | 13812 KB | Output is correct |
3 | Correct | 494 ms | 13308 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1073 ms | 15596 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 899 ms | 15692 KB | Output is correct |
2 | Runtime error | 329 ms | 34092 KB | Memory limit exceeded |
3 | Halted | 0 ms | 0 KB | - |