답안 #235548

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
235548 2020-05-28T13:46:59 Z golazcc83 학교 설립 (IZhO13_school) C++14
25 / 100
103 ms 12012 KB
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
 
#define MINF -1000000000000000000
 
using namespace std;
typedef long long ll;
 
const int MAXN = 300001;
int N, M, S;
 
struct city {
    ll a, b;
} c[MAXN];
 
struct descCompBA{
    bool operator()(const city &s1, const city &s2) {
        return s1.b - s1.a < s2.b - s2.a;
    }
};
 
bool descCompA(const city &s1, const city &s2) {
    if(s1.a != s2.a) return s1.a > s2.a;
    return s1.b < s2.b;
}
 
ll An[MAXN], Bn[MAXN];
 
int main() {
    scanf("%d %d %d", &N, &M, &S);
    for(int i = 0; i < N; ++i) {
        scanf("%lld %lld", &An[i], &Bn[i]);
        c[i].a = An[i];
        c[i].b = Bn[i];
    }
    
    ll res = 0;
    priority_queue<city, vector<city>, descCompBA> pq;
    for(int i = 0; i < M; ++i) {
        res += c[i].a;
        pq.push(c[i]);
    }
 
    for(int i = M; i < M + S; ++i) {
        city tc = pq.top();
        if(c[i].b - c[i].a > tc.b - tc.a)
            res += c[i].b;
        else {
            res += c[i].a + tc.b - tc.a;
            pq.pop();
            pq.push(c[i]);
        }
    }
 
    printf("%lld\n", res);
}

Compilation message

school.cpp: In function 'int main()':
school.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &N, &M, &S);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
school.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld", &An[i], &Bn[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 Incorrect 5 ms 384 KB Output isn't correct
5 Incorrect 5 ms 384 KB Output isn't correct
6 Incorrect 5 ms 384 KB Output isn't correct
7 Incorrect 7 ms 512 KB Output isn't correct
8 Correct 6 ms 768 KB Output is correct
9 Incorrect 6 ms 640 KB Output isn't correct
10 Incorrect 6 ms 640 KB Output isn't correct
11 Incorrect 6 ms 512 KB Output isn't correct
12 Incorrect 6 ms 512 KB Output isn't correct
13 Incorrect 18 ms 2300 KB Output isn't correct
14 Incorrect 29 ms 3300 KB Output isn't correct
15 Incorrect 48 ms 5368 KB Output isn't correct
16 Correct 62 ms 6772 KB Output is correct
17 Incorrect 81 ms 9500 KB Output isn't correct
18 Incorrect 83 ms 10180 KB Output isn't correct
19 Incorrect 89 ms 10732 KB Output isn't correct
20 Incorrect 103 ms 12012 KB Output isn't correct