제출 #245652

#제출 시각아이디문제언어결과실행 시간메모리
245652Mercenary학교 설립 (IZhO13_school)C++14
100 / 100
144 ms11888 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/trie_policy.hpp> #define pb push_back #define mp make_pair #define taskname "A" using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair<int,int> ii; typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; const int maxn = 3e5 + 5; const int mod = 1e9 + 7; const int logn = log2(maxn) + 1; int n , m , s; ii a[maxn]; ll pre[maxn] ,suf[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(taskname".INP","r")){ freopen(taskname".INP", "r",stdin); freopen(taskname".OUT", "w",stdout); } cin >> n >> m >> s; for(int i = 1 ; i <= n ; ++i)cin >> a[i].first >> a[i].second; sort(a + 1 , a + n + 1 , [&](const ii x , const ii y){ return x.first - x.second > y.first - y.second; }); priority_queue<ll,vector<ll>,greater<ll>> pq; for(int i = 1 ; i <= n ; ++i){ pq.push(a[i].first); pre[i] = pre[i - 1] + a[i].first; while(pq.size() > m){ pre[i] -= pq.top(); pq.pop(); } } while(pq.size())pq.pop(); for(int i = n ; i >= 1 ; --i){ pq.push(a[i].second); suf[i] = suf[i + 1] + a[i].second; while(pq.size() > s){ suf[i] -= pq.top(); pq.pop(); } } ll res = 0; for(int i = 0 ; i <= n ; ++i)res = max(res , pre[i] + suf[i + 1]); cout << res; }

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

school.cpp: In function 'int main()':
school.cpp:41:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(pq.size() > m){
               ~~~~~~~~~~^~~
school.cpp:50:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(pq.size() > s){
               ~~~~~~~~~~^~~
school.cpp:29:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".INP", "r",stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
school.cpp:30:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".OUT", "w",stdout);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...