# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1162691 | cbnhtmanh | Nivelle (COCI20_nivelle) | C++20 | 17 ms | 584 KiB |
#include <bits/stdc++.h>
#define fi(i, a, b) for( int i = a; i <= b; i++ )
#define fid(i, a, b) for( int i = a; i >= b; i-- )
#define getbit(x, i) ((x>>i)&1)
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define st first
#define nd second
#define mp make_pair
#define HTManh ""
#define maxn 100009
#define endl '\n'
using namespace std;
int test;
int n;
string str;
int chu[26];
set<int> s;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(NULL); cout.tie(NULL);
if (fopen(HTManh".inp", "r"))
{
freopen(HTManh".inp", "r", stdin);
freopen(HTManh".out", "w", stdout);
}
cin >> n >> str;
str = ' ' + str;
s.insert(0);
pll res = {1,0};
int dau, cuoi;
dau = cuoi = 1;
fi(i,1,n)
{
if (chu[str[i]-'a'] != 0)
{
s.erase(chu[str[i]-'a']);
}
chu[str[i]-'a'] = i;
int dem = s.size();
for(int x: s)
{
//cout << i << "|" << dem << "/" << (i-x) << endl;
if (res.st*(i-x) > res.nd*dem)
{
res = {dem, i};
dau = x+1;
cuoi = i;
}
dem--;
}
s.insert(i);
}
cout << dau << " " << cuoi << endl;
}
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... |