Submission #502515

# Submission time Handle Problem Language Result Execution time Memory
502515 2022-01-06T07:47:13 Z ismoilov Schools (IZhO13_school) C++14
30 / 100
213 ms 17328 KB
#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;
	fp(i,0,n){
		s += c[i].first.second;
		sc.insert(c[i].first.second);
		if(sc.size() > ss)
			s -= *sc.begin(), sc.erase(*sc.begin());
		pr[i] = s;
	}
	s = 0;
	sc.clear();
	fmm(i,n-1,0){
		s += c[i].second;
		sc.insert(c[i].second);
		if(sc.size() > m)
			s -= *sc.begin(), sc.erase(*sc.begin());
		rp[i] = s;
	}
	ll ans = 0;
	fp(i,0,n){
		ans = max(ans, (ll)(pr[i]+rp[i+1]));
	}
	cout << ans;
}
int main()
{
	IOS;
	S();
}

Compilation message

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: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:24:2: note: in expansion of macro 'fp'
   24 |  fp(i,0,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:9:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    9 | #define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
      |                            ^
school.cpp:33:2: note: in expansion of macro 'fmm'
   33 |  fmm(i,n-1,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: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:41:2: note: in expansion of macro 'fp'
   41 |  fp(i,0,n){
      |  ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Incorrect 1 ms 352 KB Output isn't correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Incorrect 2 ms 588 KB Output isn't correct
8 Correct 2 ms 716 KB Output is correct
9 Incorrect 2 ms 588 KB Output isn't correct
10 Incorrect 3 ms 716 KB Output isn't correct
11 Incorrect 3 ms 660 KB Output isn't correct
12 Incorrect 2 ms 576 KB Output isn't correct
13 Incorrect 18 ms 3132 KB Output isn't correct
14 Incorrect 39 ms 4280 KB Output isn't correct
15 Incorrect 62 ms 6664 KB Output isn't correct
16 Incorrect 127 ms 14644 KB Output isn't correct
17 Incorrect 146 ms 13832 KB Output isn't correct
18 Incorrect 161 ms 14004 KB Output isn't correct
19 Incorrect 165 ms 15244 KB Output isn't correct
20 Incorrect 213 ms 17328 KB Output isn't correct