# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
736136 | marvinthang | Nivelle (COCI20_nivelle) | C++17 | 46 ms | 644 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 : @marvinthang *
* date : 10 / 02 / 2022 *
******************************/
#include <bits/stdc++.h>
using namespace std;
#define superspeed ios_base::sync_with_stdio(false); cin.tie(nullptr); // cout.tie(nullptr);
#define file(name) if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
template <class U, class V> ostream & operator << (ostream& out, const pair<U, V> &p) { return out << '(' << p.first << ", " << p.second << ')'; }
template <class T> ostream & operator << (ostream &out, const vector<T> &vt) { out << '{'; for (size_t i = 0; i + 1 < vt.size(); i++) out << vt[i] << ", "; if (!vt.empty()) out << vt.back(); return out << '}'; }
const int MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795; // acos(-1.0); atan(-1.0);
const int dir[] = {0, 1, 0, -1, 0}; // {0, 1, 1, -1, -1, 1, 0, -1, 0};
const long long oo = 1e18;
const int MAX = 1e5 + 5;
int N, last[26], tmp[27];
string S;
int main(void) {
superspeed;
file("coci1920_r4_nivelle");
cin >> N >> S;
int resL = -1, resR = -1, res = 26;
memset(last, -1, sizeof(last));
tmp[26] = -1;
for (int i = 0; i < N; ++i) {
int c = S[i] - 'a';
last[c] = i;
for (int j = 0; j < 26; ++j) tmp[j] = last[j];
sort(tmp, tmp + 26, greater<int> ());
for (int j = 1; j <= 26; ++j) {
if (res * (i - tmp[j]) > j * (resR - resL + 1)) {
resL = tmp[j] + 1;
resR = i;
res = j;
}
}
}
cout << resL + 1 << ' ' << resR + 1 << '\n';
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... |