제출 #79338

#제출 시각아이디문제언어결과실행 시간메모리
79338SaboonOne-Way Streets (CEOI17_oneway)C++14
0 / 100
2 ms376 KiB
#include <iostream> #include <queue> #include <stack> #include <vector> #include <cstring> #include <cmath> #include <map> #include <unordered_map> #include <set> #include <algorithm> #include <iomanip> #define F first #define S second #define PB push_back #define PF push_front #define MP make_pair using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; const int maxn = 1e5 + 10; const int maxm = 1e5 + 10; const int mod = 1e9 + 7; ld p[maxn], q[maxn]; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; for (int i = 1; i <= n; i++) cin >> p[i] >> q[i]; sort (p + 1, p + n + 1, greater <ld> ()); sort (q + 1, q + n + 1, greater <ld> ()); ld ans = 0, fi = 0, se = 0; int idxse = 0; for (int idxfi = 1; idxfi <= n; idxfi ++) { fi += p[idxfi] - 1; se --; ans = max (ans, min (fi, se)); // cout << idxfi << " " << idxse << " -> " << fi << " " << se << endl; while (se < fi and idxse < n) { idxse ++; se += q[idxse] - 1; fi --; // cout << idxfi << " " << idxse << " -> " << fi << " " << se << endl; ans = max (ans, min (fi, se)); } } cout << fixed << setprecision (4) << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...