답안 #116915

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116915 2019-06-14T04:18:30 Z nhimnam120 Doktor (COCI17_doktor) C++14
0 / 100
236 ms 86176 KB
#include<bits/stdc++.h>
using namespace std;
long long fixedd[500005];
long long a[500005];
vector<long long> tam1[500005];
vector<long long> tam2[500005];
long long ans1,ans2;
signed main(){
	ios_base::sync_with_stdio(0);
	long long n;
	cin >> n;
	for(long long i=1;i<=n;i++){
		cin >> a[i];
		fixedd[i]=fixedd[i-1];
		if(a[i]==i){
			fixedd[i]++;
		}
		if((a[i]+i)%2==0){
			tam1[(a[i]+i)/2].push_back(abs(a[i]-i)/2);
		}
		else{
			tam2[(a[i]+i)/2].push_back(abs(a[i]-i)/2);
		}
	}
	ans1 = a[1];
	ans2 = a[1];
	long long mdx=-10000;
	for(long long i=1;i<=n;i++){
		if(tam1[i].size()==0){
			continue;
		}
		sort(tam1[i].begin(),tam1[i].end());
		for(long long j = tam1[i].size()-1;i>=0;i--){
			if(mdx < j + 1 - (fixedd[i+tam1[i][j]]-fixedd[i-tam1[i][j]-1])){
				mdx = j + 1 - (fixedd[i+tam1[i][j]]-fixedd[i-tam1[i][j]-1]);
				ans1 = a[i-tam1[i][j]];
				ans2 = a[i+tam1[i][j]];
			}
		}
	}
	for(long long i=0;i<n;i++){
		if(tam2[i].size()==0){
			continue;
		}
		for(long long j=tam2[i].size()-1;j>=0;j--){
			if(mdx < j + 1 - ( fixedd[ i + tam2[i][j] ] - fixedd[ i - tam2[i][j] ] ) ){
				mdx = j + 1 - ( fixedd[ i + tam2[i][j] ] - fixedd[ i - tam2[i][j] ] );
				ans1 = a[i-tam2[i][j]+1];
				ans2 = a[i+tam2[i][j]];
			}
		}
	}
	cout << ans1 << " " << ans2;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 48 ms 47480 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 47 ms 47520 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 49 ms 47436 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 48 ms 47708 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 48 ms 47948 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 49 ms 47836 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 95 ms 48348 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 74 ms 54660 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 236 ms 86176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 152 ms 70232 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -