Submission #119941

# Submission time Handle Problem Language Result Execution time Memory
119941 2019-06-22T17:04:39 Z tutis medians (balkan11_medians) C++17
0 / 100
103 ms 20184 KB
/*input
5
1 3 3 4 5
*/
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	int m[n];
	for (int i = 0; i < n; i++)
		cin >> m[i];
	set<int>nebus;
	for (int i = 1; i <= 2 * n - 1; i++)
		nebus.insert(i);
	for (int i = 0; i < n; i++)
		nebus.erase(m[i]);
	deque<int>answer;
	for (int i = n - 1; i > 0; i--)
	{
		nebus.insert(m[i]);
		if (m[i] == m[i - 1])
		{
			auto it = nebus.lower_bound(m[i]);
			assert(it != nebus.end());
			answer.push_front(*it);
			nebus.erase(it);
			it = nebus.upper_bound(m[i]);
			assert(it != nebus.begin());
			it--;
			answer.push_front(*it);
			nebus.erase(it);
		}
		else
		{
			if (m[i] > m[i - 1])
			{
				auto it = nebus.lower_bound(m[i]);
				assert(it != nebus.end());
				answer.push_front(*it);
				nebus.erase(it);
				it = nebus.lower_bound(m[i]);
				assert(it != nebus.end());
				answer.push_front(*it);
				nebus.erase(it);
			}
			else
			{
				auto it = nebus.upper_bound(m[i]);
				assert(it != nebus.begin());
				it--;
				answer.push_front(*it);
				nebus.erase(it);
				it = nebus.upper_bound(m[i]);
				assert(it != nebus.begin());
				it--;
				answer.push_front(*it);
				nebus.erase(it);
			}
		}
	}
	assert(nebus.size() == 1);
	answer.push_front(m[0]);
	for (int i : answer)
		cout << i << " ";
}
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 2 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Incorrect 2 ms 384 KB Not a permutation
4 Runtime error 2 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 2 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 3 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 3 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 5 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 7 ms 2048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 13 ms 3712 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 28 ms 6704 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 61 ms 13176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 103 ms 20184 KB Execution killed with signal 11 (could be triggered by violating memory limits)