제출 #235593

#제출 시각아이디문제언어결과실행 시간메모리
235593golazcc83학교 설립 (IZhO13_school)C++14
25 / 100
176 ms20556 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, idx; } c[MAXN]; bool descCompA(const city &s1, const city &s2) { if(s1.a != s2.a) return s1.a > s2.a; return s1.b > s2.b; } bool descCompB(const city &s1, const city &s2) { return s1.b > s2.b; } struct ascCompBA{ bool operator()(const city &s1, const city &s2) { if(s1.b - s1.a != s2.b - s2.a) return s1.b - s1.a < s2.b - s2.a; return s1.b > s2.b; } }; ll An[MAXN], Bn[MAXN]; int con[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); for(int i = 0; i < N; ++i) c[i].idx = i; ll res = 0; priority_queue<city, vector<city>, ascCompBA> pqsm; fill(con, con + M, 1); for(int i = 0; i < M; ++i) { res += c[i].a; pqsm.push(c[i]); } for(int i = M; i < M + S; ++i) { city tc = pqsm.top(); if(c[i].b - c[i].a >= tc.b - tc.a) { res += c[i].b; con[i] = 2; } else { res += c[i].a + tc.b - tc.a; pqsm.pop(); pqsm.push(c[i]); con[i] = 1; con[tc.idx] = 2; } } priority_queue<ll, vector<ll>, greater<ll>> pqm; for(int i = 0; i < M + S; ++i) if(con[i] == 2) pqm.push(c[i].b); sort(c + M + S, c + N, descCompB); for(int i = M + S; i < N; ++i) { if(c[i].b > pqm.top()) { res += c[i].b - pqm.top(); pqm.pop(); pqm.push(c[i].b); } else break; } printf("%lld\n", res); }

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

school.cpp: In function 'int main()':
school.cpp:40: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:42: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...