답안 #148737

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148737 2019-09-01T05:01:02 Z 코딩은 체육과목입니다(#3561, jwvg0425, 16silver, jhuni) 십자가 놓기 (FXCUP4_cross) C++17
100 / 100
131 ms 8860 KB
#include "cross.h"
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

i64 SelectCross(int K, std::vector<int> I, std::vector<int> O) 
{
    int n = I.size();

    vector<ii64> arr(n);

    for (int i = 0; i < n; i++)
    {
        arr[i].xx = I[i];
        arr[i].yy = O[i];
    }

    sort(all(arr));

    priority_queue<i64, vector<i64>, greater<i64>> maxw;
    i64 ans = 0;

    for (int i = n - 1; i >= 0; i--)
    {
        maxw.push(arr[i].yy);

        if (maxw.size() > K)
            maxw.pop();
        
        if (maxw.size() == K)
            ans = max(ans, arr[i].xx * (2 * maxw.top() - arr[i].xx));
    }

	return ans;
}

Compilation message

cross.cpp: In function 'i64 SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:49:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (maxw.size() > K)
             ~~~~~~~~~~~~^~~
cross.cpp:52:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (maxw.size() == K)
             ~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 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 7 ms 384 KB Output is correct
5 Correct 13 ms 768 KB Output is correct
6 Correct 116 ms 6760 KB Output is correct
7 Correct 121 ms 6636 KB Output is correct
8 Correct 115 ms 6760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 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 7 ms 384 KB Output is correct
5 Correct 13 ms 768 KB Output is correct
6 Correct 116 ms 6760 KB Output is correct
7 Correct 121 ms 6636 KB Output is correct
8 Correct 115 ms 6760 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 12 ms 792 KB Output is correct
13 Correct 65 ms 3672 KB Output is correct
14 Correct 116 ms 6764 KB Output is correct
15 Correct 130 ms 6764 KB Output is correct
16 Correct 125 ms 6760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 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 7 ms 384 KB Output is correct
5 Correct 13 ms 768 KB Output is correct
6 Correct 116 ms 6760 KB Output is correct
7 Correct 121 ms 6636 KB Output is correct
8 Correct 115 ms 6760 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 12 ms 792 KB Output is correct
13 Correct 65 ms 3672 KB Output is correct
14 Correct 116 ms 6764 KB Output is correct
15 Correct 130 ms 6764 KB Output is correct
16 Correct 125 ms 6760 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 13 ms 1024 KB Output is correct
20 Correct 69 ms 3828 KB Output is correct
21 Correct 116 ms 5484 KB Output is correct
22 Correct 126 ms 6760 KB Output is correct
23 Correct 127 ms 6760 KB Output is correct
24 Correct 129 ms 7124 KB Output is correct
25 Correct 131 ms 8808 KB Output is correct
26 Correct 120 ms 8860 KB Output is correct