제출 #611840

#제출 시각아이디문제언어결과실행 시간메모리
611840ekwoo학교 설립 (IZhO13_school)C++17
75 / 100
103 ms3700 KiB
#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); }

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

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 timeMemoryGrader output
Fetching results...