# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
209743 | kapsel | Difference (POI11_roz) | C++14 | 331 ms | 8464 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define LD long double
vector<int> wyst[26];
const int INF = 1e9 + 2137;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
string s;
cin>>s;
for(int i=0; i<n; i++) {
wyst[s[i]-97].push_back(i);
}
int wynik = 0;
for(int a=0; a<26; a++) {
for(int b=0; b<26; b++) {
vector<int> ciag;
int i = 0;
int j = 0;
int suma = 0;
int minimum = INF;
int w = 0;
int sumap = 0;
while(i<wyst[a].size() || j<wyst[b].size()) {
int ob;
if(i<wyst[a].size() && j<wyst[b].size()) {
if(wyst[a][i]<wyst[b][j]) {
ob = 1;
i++;
}
else {
ob = -1;
j++;
}
}
else if(i<wyst[a].size()) {
i++;
ob = 1;
}
else {
j++;
ob = -1;
}
suma+=ob;
if(ob==-1) {
minimum = min(minimum, sumap);
sumap = suma;
}
w = max(w, suma-minimum);
}
wynik = max(wynik, w);
}
}
cout<<wynik;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |