Submission #502519

#TimeUsernameProblemLanguageResultExecution timeMemory
502519ismoilovSchools (IZhO13_school)C++14
30 / 100
219 ms13904 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define all(x) (x).rbegin(), (x).rend() #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++) #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++) #define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--) #define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--) const int maxx = 3e5+5; int a[maxx], b[maxx], pr[maxx], rp[maxx]; void S() { int n, ss, m; cin >> n >> ss >> m; vector <pair<pair<int, int>, int>> c; fp(i,0,n){ cin >> a[i] >> b[i]; c.push_back({{a[i]-b[i], a[i]}, b[i]}); } sort(all(c)); multiset <int> sc; ll s = 0; fpp(i,1,n){ s += c[i-1].first.second; sc.insert(c[i-1].first.second); if(sc.size() > ss) s -= *sc.begin(), sc.erase(*sc.begin()); pr[i] = s; } s = 0; sc.clear(); fm(i,n,0){ s += c[i-1].second; sc.insert(c[i-1].second); if(sc.size() > m) s -= *sc.begin(), sc.erase(*sc.begin()); rp[i] = s; } ll ans = 0; fpp(i,0,n){ ans = max(ans, (ll)(pr[i]+rp[i+1])); } cout << ans; } int main() { IOS; S(); }

Compilation message (stderr)

school.cpp: In function 'void S()':
school.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
school.cpp:17:2: note: in expansion of macro 'fp'
   17 |  fp(i,0,n){
      |  ^~
school.cpp:7:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
school.cpp:24:2: note: in expansion of macro 'fpp'
   24 |  fpp(i,1,n){
      |  ^~~
school.cpp:27:16: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |   if(sc.size() > ss)
      |      ~~~~~~~~~~^~~~
school.cpp:8:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    8 | #define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
      |                           ^
school.cpp:33:2: note: in expansion of macro 'fm'
   33 |  fm(i,n,0){
      |  ^~
school.cpp:36:16: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |   if(sc.size() > m)
      |      ~~~~~~~~~~^~~
school.cpp:7:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    7 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
school.cpp:41:2: note: in expansion of macro 'fpp'
   41 |  fpp(i,0,n){
      |  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...