# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1257423 | Mike_Vu | Sure Bet (CEOI17_sure) | C++17 | 44 ms | 2224 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dou;
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define BITJ(x, j) (((x)>>(j))&1)
#define MASK(j) (1LL<<(j))
#define ALL(v) v.begin(), v.end()
template<typename T> bool maximize(T &x, const T &y) {
if (x < y) {x = y; return 1;}
return 0;
}
template<typename T> bool minimize(T &x, const T &y) {
if (x > y) {x = y; return 1;}
return 0;
}
const int maxn = 1e5+5;
int n;
vector<dou> a, b;
dou ans = 0;
void solve() {
int j = 0;
dou s1 = 0, s2 = 0;
for (int i = 0; i < n; i++) {
s1 += a[i];
while (j < n && b[j]+s2 <= s1) {
s2 += b[j];
++j;
}
maximize(ans, min(s1, s2)-(i+1+j));
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
#define name "sure"
if (fopen(name".inp", "r")) {
freopen(name".inp", "r", stdin);
freopen(name".out", "w", stdout);
}
cin >> n;
for (int i= 1; i <= n; i++) {
dou x, y;
cin >> x >> y;
a.pb(x);
b.pb(y);
}
sort(ALL(a), greater<dou>());
sort(ALL(b), greater<dou>());
solve();
//swap
swap(a, b);
solve();
cout << fixed<<setprecision(4)<<ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |