답안 #521448

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
521448 2022-02-02T07:16:55 Z Rasoul006 Doktor (COCI17_doktor) C++17
10 / 100
1000 ms 5200 KB
#include <bits/stdc++.h>

#define endl "\n"

typedef long long ll;

using namespace std;

const int N = 1e6+5;
ll n , a[200009] , pre[200009] ;
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]++ ;
        }
    }
    for(int i = 1 ;i <= n ;i++){
        pre[i] += pre[i-1] ;
    }
    ll mx = 0 ;
    pair < ll , ll > best=  {0 , 0} ;
    for(ll i = 1 ; i <= n ; i++){
        ll l = min(i , a[i]) , r = max(i , a[i]) ;
        ll q = pre[a[i] - 1] + (pre[n] - pre[r]) ;
//        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(q >= mx){
            mx = q ;
            best = {max(a[i]  , i) , min(i , a[i])} ;
        }
    }
    cout << best.first << " "  << best.second ;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 424 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Failed 21 ms 524 KB Checker failed - contact admins or jury
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1059 ms 2232 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 5160 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 18 ms 5200 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -