답안 #84442

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
84442 2018-11-15T07:54:55 Z farukkastamonuda 학교 설립 (IZhO13_school) C++14
25 / 100
353 ms 21728 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(x[a.se]>x[b.se]) return true;
	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;
	for(int i=1;i<=n;i++){
		z[i]=mp(mp(y[i]-x[i],y[i]),i);
	}
	memset(vis,0,sizeof(vis));
	cev=0;
	cnt=0;
	sort(z+1,z+n+1);
	for(int i=1;i<=s;i++){
		cev+=z[i].fi.se;
		vis[z[i].se]=1;
	}
	sort(z+1,z+n+1,cmp2);
	for(int i=1;i<=n;i++){
		if(cnt==m) break;
		if(vis[z[i].se]==1) continue;
		cnt++;
		cev+=x[z[i].se];
	}
	mx=max(mx,cev);
	printf("%lld\n",mx);
	return 0;
}

Compilation message

school.cpp: In function 'int main()':
school.cpp:23: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:25: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]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2684 KB Output is correct
3 Correct 4 ms 2856 KB Output is correct
4 Incorrect 4 ms 2924 KB Output isn't correct
5 Incorrect 4 ms 2924 KB Output isn't correct
6 Incorrect 4 ms 2924 KB Output isn't correct
7 Incorrect 7 ms 3044 KB Output isn't correct
8 Correct 7 ms 3044 KB Output is correct
9 Incorrect 7 ms 3072 KB Output isn't correct
10 Incorrect 7 ms 3072 KB Output isn't correct
11 Incorrect 8 ms 3072 KB Output isn't correct
12 Incorrect 8 ms 3172 KB Output isn't correct
13 Incorrect 40 ms 5100 KB Output isn't correct
14 Incorrect 84 ms 7728 KB Output isn't correct
15 Incorrect 174 ms 12848 KB Output isn't correct
16 Correct 198 ms 14112 KB Output is correct
17 Incorrect 219 ms 16560 KB Output isn't correct
18 Incorrect 236 ms 17968 KB Output isn't correct
19 Incorrect 353 ms 19336 KB Output isn't correct
20 Incorrect 299 ms 21728 KB Output isn't correct