#include <iostream>
#include <algorithm>
#include <set>
#include <deque>
#include <queue>
using namespace std;
int *arr, **occ;
int main(){
int n;
cin >> n;
char c;
arr = new int[n];
occ = new int*[n+1];
for(int i = 0; i < n; i++){
cin >> c;
arr[i] = c - 'a';
occ[i] = new int[26];
}
occ[n] = new int[26];
occ++;
for(int i = 0; i < 26; i++) occ[-1][i] = occ[0][i] = 0;
occ[0][arr[0]] = 1;
for(int i = 1; i < n; i++){
for(int j = 0; j < 26; j++){
occ[i][j] = occ[i-1][j];
}
occ[i][arr[i]]++;
}
int ml = 0, mr = 0;
double m = 1;
for(int i = 0; i < n; i++){
set<int> x;
for(int j = i; j < n; j++){
x.insert(arr[j]);
if((double)x.size() / (j - i + 1) < m){
ml = i;
mr = j;
m = (double)x.size() / (j - i + 1);
}
}
}
cout << (ml+1) << ' ' << (mr+1) << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
75 ms |
504 KB |
Output is correct |
2 |
Correct |
70 ms |
504 KB |
Output is correct |
3 |
Correct |
66 ms |
504 KB |
Output is correct |
4 |
Correct |
66 ms |
504 KB |
Output is correct |
5 |
Correct |
71 ms |
604 KB |
Output is correct |
6 |
Correct |
78 ms |
508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1097 ms |
12408 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1089 ms |
12536 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1085 ms |
12540 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |