답안 #84399

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
84399 2018-11-15T06:50:59 Z farukkastamonuda 학교 설립 (IZhO13_school) C++14
20 / 100
369 ms 17020 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,y,vis[li],cev,mx;
ii p[li],z[li];
bool cmp(ii a,ii b){
	if(a.fi.fi>b.fi.fi) return true;
	if(a.fi.fi<b.fi.fi) return false;
	if(a.fi.fi-a.fi.se>b.fi.fi-b.fi.se) return true;
	return false;
}
bool cmp2(ii a,ii b){
	if(a.fi.se>b.fi.se) return true;
	if(a.fi.se<b.fi.se) return false;
	if(a.fi.se-a.fi.fi>b.fi.se-b.fi.fi) return true;
	return false;
}
int main(){
	scanf("%lld %lld %lld",&n,&m,&s);
	for(int i=1;i<=n;i++){
		scanf("%lld %lld",&x,&y);
		p[i]=mp(mp(x,y),i);
		z[i]=mp(mp(x,y),i);
	}
	sort(z+1,z+n+1,cmp);
	for(int i=1;i<=m;i++){
		cev+=z[i].fi.fi;
		vis[z[i].se]=1;
	}
	sort(z+1,z+n+1,cmp2);
	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+=z[i].fi.se;
	}
	mx=cev;
	memset(vis,0,sizeof(vis));
	cev=0;
	sort(z+1,z+n+1,cmp2);
	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:27: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:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld",&x,&y);
   ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2804 KB Output is correct
3 Correct 4 ms 2856 KB Output is correct
4 Incorrect 4 ms 2856 KB Output isn't correct
5 Incorrect 5 ms 2856 KB Output isn't correct
6 Incorrect 5 ms 2856 KB Output isn't correct
7 Incorrect 10 ms 3088 KB Output isn't correct
8 Incorrect 8 ms 3104 KB Output isn't correct
9 Incorrect 11 ms 3104 KB Output isn't correct
10 Incorrect 8 ms 3180 KB Output isn't correct
11 Incorrect 8 ms 3180 KB Output isn't correct
12 Incorrect 8 ms 3180 KB Output isn't correct
13 Incorrect 42 ms 4600 KB Output isn't correct
14 Incorrect 96 ms 6528 KB Output isn't correct
15 Correct 182 ms 10308 KB Output is correct
16 Incorrect 212 ms 11384 KB Output isn't correct
17 Incorrect 236 ms 13180 KB Output isn't correct
18 Incorrect 262 ms 14204 KB Output isn't correct
19 Incorrect 279 ms 15228 KB Output isn't correct
20 Incorrect 369 ms 17020 KB Output isn't correct