Submission #611830

# Submission time Handle Problem Language Result Execution time Memory
611830 2022-07-29T07:59:36 Z ekwoo Schools (IZhO13_school) C++17
75 / 100
102 ms 6960 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;
    int 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("%d",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 0 ms 304 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 392 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 392 KB Output is correct
13 Correct 13 ms 1212 KB Output is correct
14 Correct 29 ms 1908 KB Output is correct
15 Correct 77 ms 3312 KB Output is correct
16 Incorrect 79 ms 4744 KB Output isn't correct
17 Incorrect 77 ms 5420 KB Output isn't correct
18 Incorrect 89 ms 5928 KB Output isn't correct
19 Incorrect 94 ms 6196 KB Output isn't correct
20 Incorrect 102 ms 6960 KB Output isn't correct