답안 #149623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149623 2019-09-01T06:51:33 Z Cafe Maru(#3599, bryan, pps789, kazel) 십자가 놓기 (FXCUP4_cross) C++17
100 / 100
379 ms 26988 KB
#include "cross.h"
#include<bits/stdc++.h>
using namespace std;

map<int,vector<int>> oi;

long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
	int N = I.size();
    for(int i=0;i<N;i++) {
        oi[-O[i]].push_back(I[i]);
    }
    long long ans = 0;
    priority_queue<int> pq;
    for(auto& [z, s] : oi) {
        int x = -z;
        for(int i : s) {
            pq.push(-i);
        }
        while(pq.size() > K) pq.pop();
        if (pq.size() == K) {
            int y = -pq.top();
            long long tmp = y*(2LL*x-y);
            if(tmp > ans) ans = tmp;
        }
    }
	return ans;
}

Compilation message

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:19:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(pq.size() > K) pq.pop();
               ~~~~~~~~~~^~~
cross.cpp:20:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (pq.size() == K) {
             ~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 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 7 ms 512 KB Output is correct
5 Correct 15 ms 1664 KB Output is correct
6 Correct 303 ms 25452 KB Output is correct
7 Correct 306 ms 25448 KB Output is correct
8 Correct 315 ms 25448 KB Output is correct
# 결과 실행 시간 메모리 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 7 ms 512 KB Output is correct
5 Correct 15 ms 1664 KB Output is correct
6 Correct 303 ms 25452 KB Output is correct
7 Correct 306 ms 25448 KB Output is correct
8 Correct 315 ms 25448 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 17 ms 1664 KB Output is correct
13 Correct 158 ms 13164 KB Output is correct
14 Correct 311 ms 25324 KB Output is correct
15 Correct 313 ms 25452 KB Output is correct
16 Correct 379 ms 25444 KB Output is correct
# 결과 실행 시간 메모리 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 7 ms 512 KB Output is correct
5 Correct 15 ms 1664 KB Output is correct
6 Correct 303 ms 25452 KB Output is correct
7 Correct 306 ms 25448 KB Output is correct
8 Correct 315 ms 25448 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 6 ms 512 KB Output is correct
12 Correct 17 ms 1664 KB Output is correct
13 Correct 158 ms 13164 KB Output is correct
14 Correct 311 ms 25324 KB Output is correct
15 Correct 313 ms 25452 KB Output is correct
16 Correct 379 ms 25444 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 6 ms 512 KB Output is correct
19 Correct 16 ms 1920 KB Output is correct
20 Correct 140 ms 13292 KB Output is correct
21 Correct 224 ms 20200 KB Output is correct
22 Correct 316 ms 25448 KB Output is correct
23 Correct 370 ms 25444 KB Output is correct
24 Correct 308 ms 25708 KB Output is correct
25 Correct 364 ms 26988 KB Output is correct
26 Correct 356 ms 26984 KB Output is correct