Submission #365453

# Submission time Handle Problem Language Result Execution time Memory
365453 2021-02-11T17:16:22 Z tfg Zalmoxis (BOI18_zalmoxis) C++17
15 / 100
122 ms 10988 KB
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int ms = 1001000;
int n, k, cur = 0;
int a[ms];
bool got = false;
int lookahead() { return cur < n ? a[cur] : -1; }
void print(int x) {
	if(got) std::cout << ' ';
	got = true;
	std::cout << x;
}
int rest = 1 << 30;

void solve(int N) {
	assert(N >= 0);
	if(lookahead() == N) {
		print(N);
		cur++;
	} else if(k > 0 && rest - (1 << N) >= k - 1) {
		print(N);
		rest -= 1 << N;
		k--;
	} else {
		solve(N-1);
		solve(N-1);
	}
}

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	std::cin >> n >> k;
	for(int i = 0; i < n; i++) {
		std::cin >> a[i];
		rest -= 1 << a[i];
	}
	solve(30);
}
# Verdict Execution time Memory Grader output
1 Runtime error 75 ms 10604 KB Execution killed with signal 6
2 Runtime error 71 ms 10476 KB Execution killed with signal 6
3 Runtime error 71 ms 10476 KB Execution killed with signal 6
4 Runtime error 71 ms 10476 KB Execution killed with signal 6
5 Runtime error 80 ms 10732 KB Execution killed with signal 6
6 Runtime error 112 ms 10988 KB Execution killed with signal 6
# Verdict Execution time Memory Grader output
1 Runtime error 74 ms 10476 KB Execution killed with signal 6
2 Runtime error 72 ms 10476 KB Execution killed with signal 6
3 Runtime error 71 ms 10476 KB Execution killed with signal 6
4 Runtime error 72 ms 10476 KB Execution killed with signal 6
5 Runtime error 75 ms 10476 KB Execution killed with signal 6
6 Runtime error 73 ms 10476 KB Execution killed with signal 6
7 Runtime error 75 ms 10476 KB Execution killed with signal 6
8 Runtime error 71 ms 10476 KB Execution killed with signal 6
9 Runtime error 80 ms 9068 KB Execution killed with signal 6
10 Runtime error 96 ms 4972 KB Execution killed with signal 6
11 Runtime error 89 ms 6508 KB Execution killed with signal 6
12 Correct 122 ms 2412 KB Output is correct
13 Correct 110 ms 2540 KB Output is correct
14 Correct 104 ms 2412 KB Output is correct