Submission #682801

# Submission time Handle Problem Language Result Execution time Memory
682801 2023-01-17T03:48:42 Z smartmonky Schools (IZhO13_school) C++14
10 / 100
102 ms 14488 KB
#include <bits/stdc++.h>
 
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long
 
using namespace std;
 
const int N = 1e5 + 1;

bool comp(pair <int,int> a, pair <int,int> b){
	return max(a.ff,a.ss) > max(b.ff,b.ss);
}
int used[N];
main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m, s;
    cin >> n >> m >> s;
    vector <int> a, b;
    vector <pair <int,int> > vp(n);
    for(int i = 0; i < n; i++){
		cin >> vp[i].ff >> vp[i].ss;
		a.pb(vp[i].ff);
		b.pb(vp[i].ss);
	}
	sort(all(vp), comp);
	sort(rall(a));
	sort(rall(b));
	int lm = m, ls = s;
	int ans = 0;
	//swap(s, m);
	for(int i = 0; i < n; i++){
		if(!(vp[i].ff >= a[lm - 1] || vp[i].ss >= b[ls - 1]) || !s && !m)continue;
		if(vp[i].ff >= a[lm - 1] && (m && !s || m && abs(a[lm] - a[lm - 1]) >= abs(b[ls] - b[ls - 1]))){
			ans += vp[i].ff;
			ls++;
			//cout <<"2 " << vp[i].ff << endl;
			m--;
		}else if(vp[i].ss >= b[ls - 1] && (!m || s && abs(a[lm] - a[lm - 1]) < abs(b[ls] - b[ls - 1]))){
			ans += vp[i].ss;
			lm++;
			s--;
			//cout <<"1 " <<  vp[i].ss << endl;
		}
	}
	cout << ans;
}

Compilation message

school.cpp:18:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   18 | main(){
      | ^~~~
school.cpp: In function 'int main()':
school.cpp:37:62: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   37 |   if(!(vp[i].ff >= a[lm - 1] || vp[i].ss >= b[ls - 1]) || !s && !m)continue;
      |                                                           ~~~^~~~~
school.cpp:38:34: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   38 |   if(vp[i].ff >= a[lm - 1] && (m && !s || m && abs(a[lm] - a[lm - 1]) >= abs(b[ls] - b[ls - 1]))){
      |                                ~~^~~~~
school.cpp:43:46: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   43 |   }else if(vp[i].ss >= b[ls - 1] && (!m || s && abs(a[lm] - a[lm - 1]) < abs(b[ls] - b[ls - 1]))){
      |                                            ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Incorrect 1 ms 340 KB Output isn't correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Incorrect 1 ms 340 KB Output isn't correct
7 Incorrect 2 ms 600 KB Output isn't correct
8 Incorrect 2 ms 596 KB Output isn't correct
9 Incorrect 2 ms 540 KB Output isn't correct
10 Incorrect 2 ms 596 KB Output isn't correct
11 Incorrect 3 ms 596 KB Output isn't correct
12 Incorrect 2 ms 596 KB Output isn't correct
13 Incorrect 14 ms 2256 KB Output isn't correct
14 Incorrect 32 ms 4188 KB Output isn't correct
15 Incorrect 69 ms 7752 KB Output isn't correct
16 Incorrect 72 ms 8100 KB Output isn't correct
17 Incorrect 74 ms 9844 KB Output isn't correct
18 Incorrect 81 ms 10800 KB Output isn't correct
19 Incorrect 90 ms 11696 KB Output isn't correct
20 Incorrect 102 ms 14488 KB Output isn't correct