제출 #1324975

#제출 시각아이디문제언어결과실행 시간메모리
1324975deh학교 설립 (IZhO13_school)C++20
25 / 100
74 ms3840 KiB
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
const ll mod = 1000000007;
using namespace std;
int n,x,y;
typedef pair<int,int> pii;
pii a[300005];
bool cmp1(pii x,pii y){
    int v1 = x.f-x.s,v2 = y.f-y.s;
    if(v1 == v2)return x.f > y.f;
    return v1 > v2;
}
bool cmp2(pii x,pii y){
    int v1 = x.s-x.f,v2 = y.s-y.f;
    if(v1 == v2)return x.s > y.s;
    return v1 > v2;
}
void iswn(){
    cin >> n >> x >> y;
    for(int i = 1;i <= n;i++)cin >> a[i].f >> a[i].s;
    sort(a+1,a+n+1,cmp1);
    ll res1 = 0,res2 = 0;
    for(int i = 1;i <= x;i++)res1 += a[i].f;
    vector<int> v;
    for(int i = x+1;i <= n;i++)v.push_back(a[i].s);
    sort(v.begin(),v.end(),greater<int>());
    for(int i = 0;i < y;i++)res1 += v[i];
    v.clear();
    for(int i = 1;i <= y;i++)res2 += a[i].s;
    for(int i = y+1;i <= n;i++)v.push_back(a[i].f);
    sort(v.begin(),v.end(),greater<int>());
    for(int i = 0;i < x;i++)res2 += v[i];
    cout << max(res1,res2);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    if(fopen("SCHOOL.INP","r")){
        freopen("SCHOOL.INP","r",stdin);
        freopen("SCHOOL.OUT","w",stdout);
    }
    int ts = 1;//cin >> ts;
    while(ts--)iswn();
    return 0;
}

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

school.cpp: In function 'int main()':
school.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen("SCHOOL.INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
school.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         freopen("SCHOOL.OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...