답안 #149068

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149068 2019-09-01T05:40:25 Z =SUM(D1:D9)(#3629, ydk1104, stet_stet, Hyperbolic) 십자가 놓기 (FXCUP4_cross) C++17
100 / 100
240 ms 14428 KB
#include "cross.h"
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
multiset<long long> S; // keep as size K
vector<pair<int,int>> cross;
long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
	int N = I.size();
	for(int i=0;i<N;++i){
		cross.push_back({I[i],O[i]});
	}
	sort(cross.begin(),cross.end(),[](auto x,auto y){return x.first>y.first;});
	long long mx=0;
	for(int i=0;i<N;++i){
		long long mi = cross[i].first;
		// put the O in the set
		S.insert(cross[i].second);
		// keep the size(evict the smallest o)
		if((int)S.size()>K) S.erase(S.begin());
		if((int)S.size()<K) continue;
		// get the smallest element
		long long statQuo = (int)(*S.begin());
		// update maxma
		if(mx < 2 * statQuo * mi - mi * mi){
			mx = 2 * statQuo * mi - mi * mi;
		}
	}

	return mx;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 13 ms 768 KB Output is correct
6 Correct 116 ms 5608 KB Output is correct
7 Correct 122 ms 5736 KB Output is correct
8 Correct 129 ms 5736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 13 ms 768 KB Output is correct
6 Correct 116 ms 5608 KB Output is correct
7 Correct 122 ms 5736 KB Output is correct
8 Correct 129 ms 5736 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 15 ms 768 KB Output is correct
13 Correct 62 ms 3056 KB Output is correct
14 Correct 116 ms 5740 KB Output is correct
15 Correct 127 ms 5740 KB Output is correct
16 Correct 128 ms 5872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 13 ms 768 KB Output is correct
6 Correct 116 ms 5608 KB Output is correct
7 Correct 122 ms 5736 KB Output is correct
8 Correct 129 ms 5736 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 15 ms 768 KB Output is correct
13 Correct 62 ms 3056 KB Output is correct
14 Correct 116 ms 5740 KB Output is correct
15 Correct 127 ms 5740 KB Output is correct
16 Correct 128 ms 5872 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 16 ms 1280 KB Output is correct
20 Correct 69 ms 3180 KB Output is correct
21 Correct 97 ms 4996 KB Output is correct
22 Correct 121 ms 5612 KB Output is correct
23 Correct 127 ms 5736 KB Output is correct
24 Correct 144 ms 6544 KB Output is correct
25 Correct 220 ms 11108 KB Output is correct
26 Correct 240 ms 14428 KB Output is correct