Submission #611840

# Submission time Handle Problem Language Result Execution time Memory
611840 2022-07-29T08:02:59 Z ekwoo Schools (IZhO13_school) C++17
75 / 100
103 ms 3700 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5+7;
vector<pair<int,int>> e;

int main(){
    int n, m, s;
    scanf("%d%d%d",&n,&m,&s); e.resize(n);
    for(auto&[x,y]:e) scanf("%d%d",&x,&y);
    sort(e.begin(), e.end(), [](const pair<int,int> x, const pair<int,int> y){return x.first-x.second < y.first-y.second;});
    priority_queue<int> pq;
    long long p=0, q=0;
    for(int i=0; i<n; ++i){
        pq.push(-e[i].second);
        q+=e[i].second;
        while(pq.size()>s) q+=pq.top(), pq.pop();
        e[i].second = q;
    }
    pq = priority_queue<int> (); q=0;
    for(int i=n; i--;){
        pq.push(-e[i].first);
        q+=e[i].first;
        while(pq.size()>m) q+=pq.top(), pq.pop();
        p = max(p, i?q+e[i-1].second:q);
    }
    printf("%lld",p);
}

Compilation message

school.cpp: In function 'int main()':
school.cpp:16:24: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   16 |         while(pq.size()>s) q+=pq.top(), pq.pop();
      |               ~~~~~~~~~^~
school.cpp:23:24: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |         while(pq.size()>m) q+=pq.top(), pq.pop();
      |               ~~~~~~~~~^~
school.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d%d%d",&n,&m,&s); e.resize(n);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
school.cpp:9:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     for(auto&[x,y]:e) scanf("%d%d",&x,&y);
      |                       ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 2 ms 388 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 392 KB Output is correct
13 Correct 14 ms 972 KB Output is correct
14 Correct 29 ms 1356 KB Output is correct
15 Correct 49 ms 1792 KB Output is correct
16 Incorrect 64 ms 3076 KB Output isn't correct
17 Incorrect 78 ms 3108 KB Output isn't correct
18 Incorrect 83 ms 3284 KB Output isn't correct
19 Incorrect 88 ms 3352 KB Output isn't correct
20 Incorrect 103 ms 3700 KB Output isn't correct