# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
500252 | Mounir | Nivelle (COCI20_nivelle) | C++14 | 70 ms | 928 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>
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define pb push_back
#define pii pair<int, int>
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
#define x first
#define y second
//#define int long long
using namespace std;
signed main(){
int nVals; cin >> nVals;
string line; cin >> line;
queue<int> occs[26];
for (int i = 0; i < nVals; ++i)
occs[line[i] - 'a'].push(i);
int l, r;
double res = 2;
for (int deb = 0; deb < nVals; ++deb){
if (deb != 0)
occs[line[deb - 1] - 'a'].pop();
vector<int> dates;
for (int c = 0; c < 26; ++c){
if (!occs[c].empty())
dates.pb(occs[c].front());
}
sort(all(dates));
for (int i = 0; i < sz(dates); ++i){
int maxi = nVals - 1;
if (i + 1 != sz(dates))
maxi = dates[i + 1] - 1;
double resCur = (i + 1)/double(maxi - deb + 1);
if (resCur < res){
res = resCur;
l = deb;
r = maxi;
}
}
}
cout << l + 1 << " " << r + 1 << endl;
return 0;
}
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... |