# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1274250 | SmuggingSpun | Nivelle (COCI20_nivelle) | C++20 | 47 ms | 15344 KiB |
#include<bits/stdc++.h>
#define taskname "E"
using namespace std;
const int lim = 1e5 + 5;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
int n;
string s;
cin >> n >> s;
vector<vector<int>>p(n + 1, vector<int>(27, n));
for(int i = n - 1; i > -1; i--){
p[i] = p[i + 1];
p[i][s[i] -= 'a'] = i;
}
int L = -1, R, C;
for(int i = 0; i < n; i++){
sort(p[i].begin(), p[i].end());
for(int j = 0; p[i][j] != n; j++){
if(L == -1 || 1LL * (j + 1) * (R - L + 1) < 1LL * C * (p[i][j + 1] - i)){
L = i;
R = p[i][j + 1] - 1;
C = j + 1;
}
}
}
cout << L + 1 << " " << R + 1;
}
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... |