Submission #167900

# Submission time Handle Problem Language Result Execution time Memory
167900 2019-12-10T18:06:02 Z GioChkhaidze Schools (IZhO13_school) C++14
15 / 100
421 ms 32456 KB
#include <bits/stdc++.h>
#define ll long long 
#define F first
#define S second
using namespace std;
const int N=3e5+5;
ll n,m,s,a[N],b[N],f[N],ans;
vector < pair < ll , pair < ll , ll > > > v;
main () {
	cin>>n>>m>>s;
	
	for (int i=1; i<=n; i++) {
		cin>>a[i]>>b[i];
		v.push_back({a[i],{i,0}});
		v.push_back({b[i],{i,1}});
	}	
	
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	
	for (int i=0; i<v.size(); i++) {
		ll type=v[i].S.S,idx=v[i].S.F;
		if (f[idx]) continue;
		if (!type) {
			if (m) {
				ans+=a[idx];
				m--;
				f[idx]=1;
			}
		}
			else {
			if (s) {
				ans+=b[idx];
				s--;
				f[idx]=1;
			}		
		}
	}
	
	cout<<ans<<endl;
}

Compilation message

school.cpp:9:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
school.cpp: In function 'int main()':
school.cpp:21:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<v.size(); i++) {
                ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Incorrect 8 ms 952 KB Output isn't correct
8 Incorrect 8 ms 1080 KB Output isn't correct
9 Incorrect 8 ms 952 KB Output isn't correct
10 Incorrect 8 ms 952 KB Output isn't correct
11 Incorrect 8 ms 952 KB Output isn't correct
12 Incorrect 8 ms 952 KB Output isn't correct
13 Incorrect 49 ms 4504 KB Output isn't correct
14 Incorrect 105 ms 8648 KB Output isn't correct
15 Incorrect 212 ms 16520 KB Output isn't correct
16 Incorrect 243 ms 16620 KB Output isn't correct
17 Incorrect 304 ms 18480 KB Output isn't correct
18 Incorrect 339 ms 20296 KB Output isn't correct
19 Incorrect 358 ms 21896 KB Output isn't correct
20 Incorrect 421 ms 32456 KB Output isn't correct