답안 #1085047

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1085047 2024-09-07T12:13:27 Z Sunbae 학교 설립 (IZhO13_school) C++17
25 / 100
156 ms 7200 KB
#include <bits/stdc++.h>
typedef long long ll;
#define z exit(0)
#define mp make_pair
#define F first
#define S second
using namespace std;
using pii = pair<int,int>;
const int N = 3e5 + 5;
pii a[N];
int v[N];
bool cmp1(int i, int j){
	return mp(a[i].F - a[i].S, a[i].S) > mp(a[j].F - a[j].S, a[j].S); 
}
bool cmp2(int i, int j){
	return mp(a[i].S - a[i].F, a[i].F) > mp(a[j].S - a[j].F, a[j].F); 
}
bool cmp11(int i, int j){
	return a[i].S > a[j].S;
}
bool cmp22(int i, int j){
	return a[i].F > a[j].F;
}
signed main(){
	int n, m[2]; scanf("%d %d %d", &n, m, m+1);
	for(int i = 0, x, y; i<n; ++i){
		scanf("%d %d", &x, &y);
		a[i] = mp(x, y);
	}
	for(int i = 0; i<n; ++i) v[i] = i;
	sort(v, v+n, cmp1);
	ll sum = 0;
	int idx = 0;
	for(int cnt = 0; cnt < m[0]; ++cnt, ++idx) sum += a[v[idx]].F;
	sort(v+idx, v+n, cmp11);
	for(int cnt = 0; cnt < m[1]; ++cnt, ++idx) sum += a[v[idx]].S;
	ll mx = sum;
	//
	sort(v, v+n, cmp2);
	sum = idx = 0;
	for(int cnt = 0; cnt < m[1]; ++cnt, ++idx) sum += a[v[idx]].S;
	sort(v+idx, v+n, cmp22);
	for(int cnt = 0; cnt < m[0]; ++cnt, ++idx) sum += a[v[idx]].F;
	mx = max(mx, sum);
	printf("%lld", mx);
}

Compilation message

school.cpp: In function 'int main()':
school.cpp:25:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |  int n, m[2]; scanf("%d %d %d", &n, m, m+1);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
school.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   scanf("%d %d", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Incorrect 1 ms 440 KB Output isn't correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Incorrect 2 ms 348 KB Output isn't correct
8 Correct 2 ms 348 KB Output is correct
9 Incorrect 2 ms 516 KB Output isn't correct
10 Incorrect 2 ms 348 KB Output isn't correct
11 Incorrect 2 ms 348 KB Output isn't correct
12 Incorrect 2 ms 568 KB Output isn't correct
13 Incorrect 16 ms 1116 KB Output isn't correct
14 Incorrect 43 ms 2136 KB Output isn't correct
15 Incorrect 103 ms 3920 KB Output isn't correct
16 Correct 97 ms 4432 KB Output is correct
17 Incorrect 124 ms 5556 KB Output isn't correct
18 Incorrect 116 ms 5968 KB Output isn't correct
19 Incorrect 132 ms 6492 KB Output isn't correct
20 Incorrect 156 ms 7200 KB Output isn't correct