(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #442956

#TimeUsernameProblemLanguageResultExecution timeMemory
442956Soumya1Nivelle (COCI20_nivelle)C++14
110 / 110
77 ms608 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; string s; cin >> n >> s; int last[26]; for (int i = 0; i < 26; i++) last[i] = -1; int nu = 1, d = 1; int l = 0, r = n - 1; for (int i = 0; i < n; i++) { last[s[i] - 'a'] = i; vector<int> v; for (int j = 0; j < 26; j++) v.push_back(last[j]); sort(v.rbegin(), v.rend()); int j; for (j = 1; j < 26; j++) { if (v[j] == -1) break; int nn = j; int dd = i - v[j]; if (nu * dd >= d * nn) nu = nn, d = dd, l = v[j] + 1, r = i; } if (nu * (i + 1) >= d * j) nu = j, d = i + 1, l = 0, r = i; } cout << l + 1 << " " << r + 1 << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...