답안 #224794

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224794 2020-04-18T20:09:45 Z MKopchev Hotel (CEOI11_hot) C++14
100 / 100
1396 ms 56868 KB
#include<bits/stdc++.h>
using namespace std;
const int nmax=5e5+42;

int n,m,want;

set< pair< pair<int/*room*/,int/*cost*/>, int/*id*/> > active;

pair<int/*gain*/,int/*wanted*/> inp[nmax];

int add[nmax];

int main()
{
    scanf("%i%i%i",&n,&m,&want);

    for(int i=1;i<=n;i++)
    {
        int cost,room;
        scanf("%i%i",&cost,&room);
        active.insert({{room,cost},i});
    }

    for(int i=1;i<=m;i++)
        scanf("%i%i",&inp[i].first,&inp[i].second);

    sort(inp+1,inp+m+1);

    for(int i=m;i>=1;i--)
    {
        set< pair< pair<int/*room*/,int/*cost*/>, int/*id*/> >::iterator it=active.lower_bound({{inp[i].second,0},0});

        if(it==active.end())continue;

        int cost=(*it).first.second;

        if(inp[i].first-cost>0)
        {
            add[i]=inp[i].first-cost;
            active.erase(it);
        }

    }

    sort(add+1,add+m+1);

    long long output=0;
    for(int i=m;i>m-want;i--)
        if(add[i]>0)output=output+add[i];

    printf("%lld\n",output);
    return 0;
}

Compilation message

hot.cpp: In function 'int main()':
hot.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i%i",&n,&m,&want);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
hot.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i%i",&cost,&room);
         ~~~~~^~~~~~~~~~~~~~~~~~~~
hot.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i%i",&inp[i].first,&inp[i].second);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 1192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 3448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 107 ms 5752 KB Output is correct
2 Correct 99 ms 6940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 377 ms 15352 KB Output is correct
2 Correct 180 ms 12132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 856 ms 30284 KB Output is correct
2 Correct 952 ms 45560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1113 ms 37880 KB Output is correct
2 Correct 1146 ms 56868 KB Output is correct
3 Correct 1396 ms 54024 KB Output is correct