Submission #224793

# Submission time Handle Problem Language Result Execution time Memory
224793 2020-04-18T20:08:25 Z MKopchev Hotel (CEOI11_hot) C++14
10 / 100
825 ms 88272 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});

        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);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 17 ms 2304 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 55 ms 7800 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 99 ms 13388 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 308 ms 37000 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 669 ms 73216 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 825 ms 88272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -