Submission #96851

# Submission time Handle Problem Language Result Execution time Memory
96851 2019-02-12T13:58:10 Z Rouge_Hugo Doktor (COCI17_doktor) C++14
90 / 100
1000 ms 62368 KB
	#include <bits/stdc++.h>
	using namespace std;
	const int mw=5*100002;
	int pr[mw],a[mw],t[mw];
	map<double,vector<pair<int,int>>>m;
	int main()
	{
		int sum=0;
		int n;cin>>n;
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
			t[a[i]]=i;
			if (a[i]==i)
			{
				sum++;	
			}
			pr[i]=sum;
		}
		for(int i=1;i<=n;i++)
		{
			double u=(a[i]+i)/2.0;
			m[u].push_back({min(a[i],i),max(a[i],i)});
		}
		int mx=0;
		pair<int,int>b;
		for(auto it :m)
		{sum=0;
		sort(m[it.first].begin(),m[it.first].end());
		reverse (m[it.first].begin(),m[it.first].end());
			for(auto pp:m[it.first])
			{
				if (mx<sum+1+pr[n]-pr[pp.second]+pr[pp.first-1])
				{
				mx=sum+1+pr[n]-pr[pp.second]+pr[pp.first-1];
				b=pp;
				}
			sum++;
			}
		}
		cout<<a[b.first]<<" "<<a[b.second];
			
	 return 0;
	
	}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 520 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 804 KB Output is correct
2 Correct 6 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1280 KB Output is correct
2 Correct 175 ms 10596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 162 ms 9240 KB Output is correct
2 Correct 55 ms 3820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1014 ms 49192 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 747 ms 29148 KB Output is correct
2 Correct 743 ms 62368 KB Output is correct