Submission #242634

# Submission time Handle Problem Language Result Execution time Memory
242634 2020-06-28T12:25:42 Z LucaDantas Sure Bet (CEOI17_sure) C++17
0 / 100
5 ms 256 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

#define double long double

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false), cout.tie(nullptr), cin.tie(nullptr)
#define sz(a) ((int)(a).size())
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define dec(i,n,a) for(int i=(n); i>=(a); i--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()

constexpr int inf = 0x3f3f3f3f;
constexpr int MAXN = 1e5 + 10;
constexpr int mod = 1000000007;

int main() {
	int n; cin >> n;
	priority_queue<double> a, b;
	rep(i,0,n) {
		double x, y;
		cin >> x >> y;
		a.push(x); b.push(y);
	}
	
	double A = 0, B = 0, ans = -10000;

	rep(i,0,2*n) {
		if(a.empty() || (B <= A && !b.empty())) {
			assert(!b.empty());
			double now = b.top();
			b.pop();
			A--;
			B += now - 1;
			ans = max(ans, min(A, B));
		}
		else if(b.empty() || A < B) {
			assert(!a.empty());
			double now = a.top();
			a.pop();
			B--;
			A += now - 1;
			ans = max(ans, min(A, B));
		}
	}

	cout << fixed;
	cout << setprecision(4);
	cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -