답안 #148842

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148842 2019-09-01T05:14:09 Z White Fairy(#3613, wifi) 십자가 놓기 (FXCUP4_cross) C++17
100 / 100
124 ms 6632 KB
#include "cross.h"
#include <bits/stdc++.h>

using namespace std;

long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
  int N = I.size();
  vector<pair<int, int>> pairs(N);
  for (int i = 0; i < N; ++i) {
    pairs[i] = {I[i], O[i]};
  }
  sort(pairs.begin(), pairs.end());
  reverse(pairs.begin(), pairs.end());
  priority_queue<int> pq;
  long long ans = 0;
  for (int i = 0; i < N; ++i) {
    pq.push(-pairs[i].second);
    while (pq.size() > K) {
      pq.pop();
    }
    if (pq.size() == K) {
      int din = pairs[i].first, dout = -pq.top();
      ans = max(ans, 1LL * dout * dout - 1LL * (dout - din) * (dout - din));
    }
  }
	return ans;
}

Compilation message

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:18:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (pq.size() > K) {
            ~~~~~~~~~~^~~
cross.cpp:21:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (pq.size() == K) {
         ~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 12 ms 640 KB Output is correct
6 Correct 110 ms 5224 KB Output is correct
7 Correct 118 ms 5228 KB Output is correct
8 Correct 111 ms 5228 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 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 12 ms 640 KB Output is correct
6 Correct 110 ms 5224 KB Output is correct
7 Correct 118 ms 5228 KB Output is correct
8 Correct 111 ms 5228 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 9 ms 384 KB Output is correct
12 Correct 13 ms 640 KB Output is correct
13 Correct 59 ms 2800 KB Output is correct
14 Correct 118 ms 5096 KB Output is correct
15 Correct 114 ms 5224 KB Output is correct
16 Correct 113 ms 5228 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 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 12 ms 640 KB Output is correct
6 Correct 110 ms 5224 KB Output is correct
7 Correct 118 ms 5228 KB Output is correct
8 Correct 111 ms 5228 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 9 ms 384 KB Output is correct
12 Correct 13 ms 640 KB Output is correct
13 Correct 59 ms 2800 KB Output is correct
14 Correct 118 ms 5096 KB Output is correct
15 Correct 114 ms 5224 KB Output is correct
16 Correct 113 ms 5228 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 12 ms 768 KB Output is correct
20 Correct 67 ms 2928 KB Output is correct
21 Correct 93 ms 4204 KB Output is correct
22 Correct 115 ms 5232 KB Output is correct
23 Correct 115 ms 5096 KB Output is correct
24 Correct 122 ms 5356 KB Output is correct
25 Correct 123 ms 6632 KB Output is correct
26 Correct 124 ms 6632 KB Output is correct