Submission #302441

# Submission time Handle Problem Language Result Execution time Memory
302441 2020-09-18T16:56:47 Z nhdtxdy Rice Hub (IOI11_ricehub) C++17
42 / 100
1000 ms 984 KB
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops, no-stack-protector")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int nax = 1e5 + 5;
int n, maxi, a[nax];
ll b;

// Subtask 3

int solve() {
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		// select a[i] as the position
		priority_queue<int, vector<int>, greater<int>> pq;
		for (int j = 1; j <= n; ++j) {
			pq.push(abs(a[i] - a[j]));
		}
		int cnt = 0, curr = 0;
		while (!pq.empty() && curr <= b) {
			++cnt;
			curr += pq.top();
			pq.pop();
		}
		if (curr > b) --cnt;
		ans = max(ans, cnt);
	}
	return ans;
}

int besthub(int R, int L, int X[], long long B) {
	n = R;
	maxi = L;
	for (int i = 0; i < R; ++i) a[i + 1] = X[i];
	b = B;
	return solve();
}

Compilation message

ricehub.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    2 | #pragma GCC optimization("unroll-loops, no-stack-protector")
      |
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 416 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 7 ms 384 KB Output is correct
22 Correct 7 ms 256 KB Output is correct
23 Correct 17 ms 384 KB Output is correct
24 Correct 16 ms 384 KB Output is correct
25 Correct 16 ms 384 KB Output is correct
26 Correct 16 ms 512 KB Output is correct
27 Correct 11 ms 512 KB Output is correct
28 Correct 11 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 63 ms 384 KB Output is correct
4 Correct 62 ms 504 KB Output is correct
5 Correct 6 ms 512 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 23 ms 384 KB Output is correct
8 Correct 23 ms 384 KB Output is correct
9 Correct 12 ms 384 KB Output is correct
10 Correct 9 ms 384 KB Output is correct
11 Correct 19 ms 384 KB Output is correct
12 Correct 19 ms 384 KB Output is correct
13 Correct 80 ms 384 KB Output is correct
14 Correct 73 ms 384 KB Output is correct
15 Correct 11 ms 384 KB Output is correct
16 Correct 11 ms 384 KB Output is correct
17 Correct 50 ms 384 KB Output is correct
18 Correct 46 ms 384 KB Output is correct
19 Correct 80 ms 384 KB Output is correct
20 Correct 72 ms 384 KB Output is correct
21 Correct 545 ms 472 KB Output is correct
22 Correct 545 ms 384 KB Output is correct
23 Execution timed out 1047 ms 384 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 984 KB Time limit exceeded
2 Halted 0 ms 0 KB -