Submission #148714

# Submission time Handle Problem Language Result Execution time Memory
148714 2019-09-01T04:59:17 Z From The Sky(#3630, WhipppedCream, top34051, zoomswk) Crosses on the Grid (FXCUP4_cross) C++17
100 / 100
128 ms 6888 KB
#include "cross.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef long long ll;

#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

const int md = 1e9+7;
const ll inf = 1e18;
const int maxn = 2e5+5;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

int n;

ll SelectCross(int K, vi I, vi O) {
	n = I.size();
	vector< ii > foo;
	for(int i = 0; i< n; i++)
	{
		foo.pb(ii(I[i], O[i]));
	}
	sort(foo.begin(), foo.end());
	reverse(foo.begin(), foo.end());
	priority_queue<int> pq;
	ll best = 0;
	for(int i = 0; i< n; i++)
	{
		pq.push(-foo[i].s);
		while(sz(pq)> K) pq.pop();
		if(sz(pq) != K) continue;
		best = max(best, 2LL*(-pq.top())*foo[i].f-1LL*foo[i].f*foo[i].f);
	}
	return best;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
5 Correct 11 ms 768 KB Output is correct
6 Correct 111 ms 5736 KB Output is correct
7 Correct 115 ms 5736 KB Output is correct
8 Correct 106 ms 5732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
5 Correct 11 ms 768 KB Output is correct
6 Correct 111 ms 5736 KB Output is correct
7 Correct 115 ms 5736 KB Output is correct
8 Correct 106 ms 5732 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 11 ms 768 KB Output is correct
13 Correct 61 ms 3180 KB Output is correct
14 Correct 113 ms 5744 KB Output is correct
15 Correct 116 ms 5740 KB Output is correct
16 Correct 110 ms 5736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
5 Correct 11 ms 768 KB Output is correct
6 Correct 111 ms 5736 KB Output is correct
7 Correct 115 ms 5736 KB Output is correct
8 Correct 106 ms 5732 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 11 ms 768 KB Output is correct
13 Correct 61 ms 3180 KB Output is correct
14 Correct 113 ms 5744 KB Output is correct
15 Correct 116 ms 5740 KB Output is correct
16 Correct 110 ms 5736 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 12 ms 640 KB Output is correct
20 Correct 64 ms 3184 KB Output is correct
21 Correct 88 ms 5104 KB Output is correct
22 Correct 116 ms 5740 KB Output is correct
23 Correct 118 ms 5740 KB Output is correct
24 Correct 117 ms 5740 KB Output is correct
25 Correct 128 ms 6632 KB Output is correct
26 Correct 111 ms 6888 KB Output is correct