답안 #151138

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
151138 2019-09-01T20:51:57 Z kuroni 십자가 놓기 (FXCUP4_cross) C++17
100 / 100
116 ms 10724 KB
#include "cross.h"
#include <bits/stdc++.h>
using namespace std;

long long SelectCross(int k, vector<int> s, vector<int> l)
{
	vector<pair<int, int>> ve;
	int n = s.size();
	long long ans = 0;
	for (int i = 0; i < n; i++)
		ve.push_back({s[i], l[i]});
	sort(ve.begin(), ve.end(), greater<pair<int, int>>());
	priority_queue<int, vector<int>, greater<int>> pq;
	for (int i = 0; i < n; i++)
	{
		pq.push(ve[i].second);
		if (pq.size() > k)
			pq.pop();
		if (pq.size() == k)
			ans = max(ans, 1LL * ve[i].first * ve[i].first + 2LL * (pq.top() - ve[i].first) * ve[i].first);
	}
	return ans;
}

Compilation message

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:17:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (pq.size() > k)
       ~~~~~~~~~~^~~
cross.cpp:19:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (pq.size() == k)
       ~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 8 ms 888 KB Output is correct
6 Correct 110 ms 7268 KB Output is correct
7 Correct 105 ms 8164 KB Output is correct
8 Correct 111 ms 8136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 8 ms 888 KB Output is correct
6 Correct 110 ms 7268 KB Output is correct
7 Correct 105 ms 8164 KB Output is correct
8 Correct 111 ms 8136 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 9 ms 1016 KB Output is correct
13 Correct 58 ms 5104 KB Output is correct
14 Correct 108 ms 9596 KB Output is correct
15 Correct 107 ms 9444 KB Output is correct
16 Correct 107 ms 9456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 8 ms 888 KB Output is correct
6 Correct 110 ms 7268 KB Output is correct
7 Correct 105 ms 8164 KB Output is correct
8 Correct 111 ms 8136 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 9 ms 1016 KB Output is correct
13 Correct 58 ms 5104 KB Output is correct
14 Correct 108 ms 9596 KB Output is correct
15 Correct 107 ms 9444 KB Output is correct
16 Correct 107 ms 9456 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 9 ms 1016 KB Output is correct
20 Correct 59 ms 5108 KB Output is correct
21 Correct 86 ms 8016 KB Output is correct
22 Correct 109 ms 9616 KB Output is correct
23 Correct 113 ms 9576 KB Output is correct
24 Correct 116 ms 9452 KB Output is correct
25 Correct 115 ms 10440 KB Output is correct
26 Correct 108 ms 10724 KB Output is correct