# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
494807 | duyanhloveav | Nivelle (COCI20_nivelle) | C++17 | 74 ms | 708 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.
/**
* author: duyanhloveav
* created: 0*.0*.2021 18:25:28
* 🥇 🐘 💯 🔥 🔥 🔥
**/
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a), _b=(b); i<_b; ++i)
#define fi first
#define se second
#define pb push_back
#define ll long long
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
const int N = 1 + 1e6;
const double INF = 1e9;
int n,d[26];
string s;
int32_t main() {
#define TASKNAME "coci1920_r4_nivelle"
ios_base::sync_with_stdio (0);
cin.tie (0);
if ( fopen( TASKNAME".inp", "r" ) ) {
freopen (TASKNAME".inp", "r", stdin);
freopen (TASKNAME".out", "w", stdout);
}
cin >> n >> s;
s = " " + s;
int lo = 0, hi = 0;
double res2 = 1e9;
for (int i = n; i >= 1; i--) {
d[s[i] - 'a'] = i;
vector<int> a = {n + 1};
for (int j = 0; j < 26; j++)
if (d[j])
a.push_back(d[j]);
sort(all(a));
for (int j = 0; j + 1 < sz(a); j++) {
double res = (double)(j + 1) / (a[j + 1] - i);
if (res2 > res) {
res2 = res;
lo = i;
hi = a[j + 1] - 1;
}
}
}
cout << lo << " " << hi;
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... |