제출 #235541

#제출 시각아이디문제언어결과실행 시간메모리
235541golazcc83Schools (IZhO13_school)C++14
25 / 100
136 ms12784 KiB
#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];
    }
    sort(c, c + N, descCompA);
    
    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);
}

컴파일 시 표준 에러 (stderr) 메시지

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]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...