# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
883607 | mgl_diamond | Nivelle (COCI20_nivelle) | C++17 | 66 ms | 552 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;
using ll = long long;
using ii = pair<int, int>;
#define foru(i, l, r) for(int i=(l); i<=(r); ++i)
#define ford(i, l, r) for(int i=(l); i>=(r); --i)
#define fore(x, v) for(auto &x : v)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define file "input"
template<class T> bool minimize(T &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> bool maximize(T &a, T b) { if (a < b) { a = b; return 1; } return 0; }
void setIO() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if (fopen(file".inp", "r")) {
freopen(file".inp", "r", stdin);
freopen(file".out", "w", stdout);
}
}
const int N = 1e5+5;
int n;
string s;
int main() {
setIO();
vector<int> lst(26);
cin >> n;
double best = N;
int a1, a2;
foru(i, 1, n) {
char c;
cin >> c;
c -= 'a';
lst[c] = i;
vector<int> range;
foru(j, 0, 25) if (lst[j] > 0)
range.push_back(lst[j]);
sort(all(range));
// cout << "I " << i << "\n";
ford(j, sz(range)-1, 0) {
int len = i - (j == 0 ? 0 : range[j-1]);
// cout << double(sz(range) - j) / double(len) << "\n";
if (double(sz(range) - j) / double(len) < best) {
a1 = i-len+1;
a2 = i;
best = double(sz(range) - j) / double(len);
}
}
}
cout << a1 << " " << a2;
}
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... |