# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
521463 |
2022-02-02T07:41:28 Z |
Rasoul006 |
Doktor (COCI17_doktor) |
C++17 |
|
1000 ms |
11736 KB |
#include <bits/stdc++.h>
#define endl "\n"
typedef long long ll;
using namespace std;
const int N = 1e6+5;
ll n , a[500009] , suf[500009] , pre[500009] ;
map < ll , ll > mp ;
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n ;
for(int i = 1 ; i <= n ; i++){
cin >> a[i] ;
if(a[i] == i){
pre[i]++ ;
suf[i]++ ;
}
}
for(int i = 1 ;i <= n ;i++){
pre[i] += pre[i-1] ;
}
for(int i = n ;i >= 1 ; i--){
suf[i] += suf[i + 1] ;
}
ll mx = pre[n] ;
pair < ll , ll > best = {1 , 1} ;
for(ll i = 1 ; i <= n ; i++){
for(int j = i ; j <= n ; j++){
ll l = i , r = j ;
ll q = (pre[l - 1] + suf[r + 1]) ;
// cout << i << " " << j << " " << q << endl ;
// cout << suf[r + 1] << " " << pre[l - 1] << endl ;
// cout << l << " " << r << " " ;
// cout << pre[a[i] - 1] << " " << pre[n] - pre[r]<< endl ;
while(r > l){
q += ((a[r] == l) + (a[l] == r)) ;
l++ , r-- ;
}
if(l == r){
q += (a[r] == r) ;
}
// cout << q << endl ;
if(q >= mx){
mx = q ;
best = {j , i} ;
}
}
}
cout << best.first << " " << best.second ;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
340 KB |
Output is correct |
2 |
Failed |
8 ms |
332 KB |
Checker failed - contact admins or jury |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
797 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1077 ms |
332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1061 ms |
460 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1079 ms |
2380 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
11736 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1084 ms |
6980 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |