답안 #1027174

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1027174 2024-07-19T01:38:25 Z toan2602 Sure Bet (CEOI17_sure) C++14
0 / 100
0 ms 344 KB
#include<bits/stdc++.h>

using namespace std;
int n;
double a[100005], b[100005];
void solve() {
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
	sort(a+1,a+1+n, greater<>());
	sort(b+1,b+1+n, greater<>());
	double ra, rb, res = 0;
	int p1, p2;
	ra = rb = 0;
	p1 = p2 = 1;
	for (int i = 1; i <= 2*n; i++) {
		if((ra < rb && p1 <= n) || p2 == n+1) {
			ra += a[p1];
			p1++;
		}
		else {
			rb += b[p2];
			p2++;
		}
		res = max(res, min(ra-i,rb-i));
	}
	cout << res;
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	if(fopen("input.inp","r")){
		freopen("input.inp", "r", stdin);
		freopen("output.out", "w", stdout);
	}
	int t = 1;
	// cin >> t;
	while(t--) {
		solve();
	}
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:32:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |   freopen("input.inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:33:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   freopen("output.out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -