답안 #992229

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
992229 2024-06-04T07:01:22 Z hariaakas646 Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>

using namespace std;

#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, j, k) for(int i=j; i<k; i++)
#define frange(i, k) forr(i, 0, k)
#define mp make_pair
#define pb push_back
#define all(vec) vec.begin(), vec.end()
#define f first
#define s second

typedef long long lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef vector<lli> vll;
typedef long double ld;

void fastio() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void usaco() {
	freopen("/home/student_visitors/v_hari_aakash_k/Desktop/IOITC_practice/input.in", "r", stdin);
}

vi v1, v2;

bool check(lli x) {
	lli x1 = 0;
	lli x2 = 0;
	int n = v1.size();
	int i1 = 0;
	int i2 = 0;
	while(true) {
		if(x1 < x) {
			if(i1 < n) {
				x1 += v1[i1];
				x1 -= 1e4;
				x2 -= 1e4;
				i1++;
			}
			else break;
		}
		if(x2 < x) {
			if(i2 < n) {
				x2 += v2[i2];
				x2 -= 1e4;
				x1 -= 1e4;
				i2++;
			}
			else break;
		}
		if(x1 >= x && x2 >= x) return true;

	}
	// printf("%lld %lld\n", x1, x2);
	return x1 >= x && x2 >= x;
}

int main() {
	// usaco();
	fastio();
	int n;
	cin >> n;


	frange(i, n) {
		ld a, b;
		cin >> a >> b;
		v1.pb(a*10000);
		v2.pb(b*10000);
	}
	sort(all(v1), greater<>());
	sort(all(v2), greater<>());
	lli lo = 0;
	lli hi = 1e15;

	while(lo != hi) {
		lli mid = (lo+hi+1)/2;
		if(check(mid)) lo = mid;
		else hi = mid-1;
	}
	cout << ld(lo) / 10000 << "\n";
}

Compilation message

sure.cpp: In function 'void usaco()':
sure.cpp:34:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |  freopen("/home/student_visitors/v_hari_aakash_k/Desktop/IOITC_practice/input.in", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -