답안 #151339

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
151339 2019-09-02T13:32:05 Z dongwon0427 십자가 놓기 (FXCUP4_cross) C++17
100 / 100
113 ms 10728 KB
#include "cross.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
long long SelectCross(int k, std::vector<int> I, std::vector<int> O) {
	int n = I.size();
	vector<pii> v;
	for(int i=0;i<n;i++) {
        v.push_back(pii(O[i], I[i]));
	}
	sort(v.begin(), v.end());

	priority_queue<int> pq;
    for(int i=n-k;i<n;i++) {
        pq.push(-v[i].second);
    }
    ll ret = (ll)v[n-k].first * v[n-k].first - (ll)(v[n-k].first + pq.top()) * (v[n-k].first + pq.top());
	for(int i=n-k-1;i>=0;i--) {
        if(-v[i].second <= pq.top()) {
            pq.pop();
            pq.push(-v[i].second);
        }
        ret = max(ret, (ll)v[i].first * v[i].first - (ll)(v[i].first + pq.top()) * (v[i].first + pq.top()));
	}
	return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 8 ms 1016 KB Output is correct
6 Correct 103 ms 9596 KB Output is correct
7 Correct 103 ms 9428 KB Output is correct
8 Correct 102 ms 9448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 8 ms 1016 KB Output is correct
6 Correct 103 ms 9596 KB Output is correct
7 Correct 103 ms 9428 KB Output is correct
8 Correct 102 ms 9448 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 8 ms 1016 KB Output is correct
13 Correct 53 ms 5076 KB Output is correct
14 Correct 102 ms 9420 KB Output is correct
15 Correct 102 ms 9572 KB Output is correct
16 Correct 101 ms 9452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 8 ms 1016 KB Output is correct
6 Correct 103 ms 9596 KB Output is correct
7 Correct 103 ms 9428 KB Output is correct
8 Correct 102 ms 9448 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 8 ms 1016 KB Output is correct
13 Correct 53 ms 5076 KB Output is correct
14 Correct 102 ms 9420 KB Output is correct
15 Correct 102 ms 9572 KB Output is correct
16 Correct 101 ms 9452 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 8 ms 1016 KB Output is correct
20 Correct 54 ms 5096 KB Output is correct
21 Correct 85 ms 8040 KB Output is correct
22 Correct 102 ms 9536 KB Output is correct
23 Correct 103 ms 9440 KB Output is correct
24 Correct 107 ms 9448 KB Output is correct
25 Correct 113 ms 10544 KB Output is correct
26 Correct 106 ms 10728 KB Output is correct