제출 #844363

#제출 시각아이디문제언어결과실행 시간메모리
844363vjudge1Nivelle (COCI20_nivelle)C++17
24 / 110
1063 ms21336 KiB
#include <bits/stdc++.h> using namespace std; #define int long long void solve(){ int n;cin >> n; int cnt[n+1][26],arr[n+1]; memset(cnt , 0 , sizeof(cnt)); for(int i = 1;i<=n;i++){ char ch;cin >> ch; arr[i] = ch - 'a'; cnt[i][arr[i]]++; for(int j = 0;j<26;j++){ cnt[i][j] += cnt[i-1][j]; } } int pay = 2*n , payda = 1 , l = 1 , r = 1; for(int i = 1;i<=n;i++){ for(int j = i;j<=n;j++){ int dif = 0 , len = j - i + 1; for(int k = 0;k<26;k++)dif += (cnt[j][k] - cnt[i-1][k]) > 0; if(pay * len > dif * payda){ pay = dif; payda = len; l = i; r = j; } } } cout << l << " " << r << endl; } signed main(){ ios_base::sync_with_stdio(0);cin.tie(0); int testcase = 1;//cin >> testcase; while(testcase--)solve(); }
#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...