(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 #487603

#TimeUsernameProblemLanguageResultExecution timeMemory
487603KazamaHoangNivelle (COCI20_nivelle)C++14
110 / 110
83 ms632 KiB
#include <bits/stdc++.h> using namespace std; int n; string s; double res = 1e9; int l = 0, r = 0; int last[26]; int main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> s; s = " " + s; for (int i = n; i >= 1; -- i) { last[s[i]-'a'] = i; vector<int> min_pos = {n+1}; for (int j = 0; j < 26; ++ j) if (last[j]) min_pos.push_back(last[j]); sort(min_pos.begin(), min_pos.end()); for (int j = 0; j + 1 < (int)min_pos.size(); ++ j) { double cur = (double)(j + 1) / (min_pos[j+1] - i); if (res > cur) { res = cur; l = i; r = min_pos[j+1] - 1; } } } cout << l << " " << r; 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...