Submission #84440

# Submission time Handle Problem Language Result Execution time Memory
84440 2018-11-15T07:51:12 Z farukkastamonuda Schools (IZhO13_school) C++14
25 / 100
185 ms 21628 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 300005
#define ii pair< pair<lo int,lo int> ,lo int> 
using namespace std;
lo int n,m,s,x[li],y[li],vis[li],cev,mx;
ii p[li],z[li];
bool cmp(ii a,ii b){
	if(y[a.se]>y[b.se]) return true;
	return false;
}
//~ bool cmp2(ii a,ii b){
	//~ if(a.fi.se-a.fi.fi>b.fi.se-b.fi.fi) return true;
	//~ if(a.fi.se>=b.fi.se) return true;
	//~ if(a.fi.se<b.fi.se) return false;
	//~ return false;
//}
int main(){
	scanf("%lld %lld %lld",&n,&m,&s);
	for(int i=1;i<=n;i++){
		scanf("%lld %lld",&x[i],&y[i]);
		p[i]=mp(mp(x[i]-y[i],x[i]),i);
		z[i]=mp(mp(x[i]-y[i],x[i]),i);
	}
	sort(z+1,z+n+1,greater<ii>());
	//~ for(int i=1;i<=n;i++){
		//~ printf("%lld %lld\n",z[i].fi.se,z[i].se);
	//~ }
	//~ return 0;
	for(int i=1;i<=m;i++){
		//printf("%lld %lld\n",z[i].fi.fi,z[i].fi.se);
		cev+=z[i].fi.se;
		vis[z[i].se]=1;
	}
	sort(z+1,z+n+1,cmp);
	int cnt=0;
	for(int i=1;i<=n;i++){
		//printf("%d %d %d\n",z[i].fi.fi,z[i].fi.se,z[i].se);
		if(cnt==s) break;
		if(vis[z[i].se]==1) continue;
		cnt++;
		cev+=y[z[i].se];
	}
	mx=cev;
	//memset(vis,0,sizeof(vis));
	//cev=0;
	//~ sort(z+1,z+n+1,cmp);
	//~ for(int i=1;i<=s;i++){
		//~ cev+=z[i].fi.se;
		//~ vis[z[i].se]=1;
	//~ }
	//~ //sort(z+1,z+n+1,cmp);
	//~ cnt=0;
	//~ for(int i=1;i<=n;i++){
		//~ //printf("%d %d %d\n",z[i].fi.fi,z[i].fi.se,z[i].se);
		//~ if(cnt==m) break;
		//~ if(vis[z[i].se]==1) continue;
		//~ cnt++;
		//~ cev+=z[i].fi.fi;
	//~ }
	//~ mx=max(mx,cev);
	printf("%lld\n",mx);
	return 0;
}

Compilation message

school.cpp: In function 'int main()':
school.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld %lld",&n,&m,&s);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
school.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld",&x[i],&y[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 452 KB Output is correct
3 Correct 2 ms 452 KB Output is correct
4 Incorrect 2 ms 492 KB Output isn't correct
5 Incorrect 2 ms 492 KB Output isn't correct
6 Incorrect 2 ms 532 KB Output isn't correct
7 Incorrect 4 ms 916 KB Output isn't correct
8 Correct 4 ms 916 KB Output is correct
9 Incorrect 4 ms 916 KB Output isn't correct
10 Incorrect 5 ms 992 KB Output isn't correct
11 Incorrect 4 ms 992 KB Output isn't correct
12 Incorrect 4 ms 1004 KB Output isn't correct
13 Incorrect 25 ms 3072 KB Output isn't correct
14 Incorrect 52 ms 6140 KB Output isn't correct
15 Incorrect 110 ms 10752 KB Output isn't correct
16 Correct 122 ms 13180 KB Output is correct
17 Incorrect 136 ms 16016 KB Output isn't correct
18 Incorrect 149 ms 17488 KB Output isn't correct
19 Incorrect 162 ms 18808 KB Output isn't correct
20 Incorrect 185 ms 21628 KB Output isn't correct