제출 #1205455

#제출 시각아이디문제언어결과실행 시간메모리
1205455MighilonSure Bet (CEOI17_sure)C++20
0 / 100
0 ms528 KiB
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG #include "../Library/debug.h" #else #define dbg(x...) #endif typedef long long ll; typedef long double ld; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<ll> vl; typedef vector<pi> vpi; typedef vector<pl> vpl; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define F0R(i, a) for (int i = 0; i < (a); ++i) #define FORd(i, a, b) for (int i = (b) - 1; i >= (a); --i) #define F0Rd(i, a) for (int i = (a) - 1; i >= 0; --i) #define trav(a, x) for (auto& a : x) #define f first #define s second #define pb push_back #define sz(x) (int)(x).size() #define all(x) x.begin(), x.end() const char nl = '\n'; const int INF = 1e9; const int MOD = 1e9 + 7; void solve(){ int n; cin>>n; vector<array<double,3>> a(n),b; F0R(i,n){ cin>>a[i][0]>>a[i][1]; a[i][0]--; a[i][1]--; a[i][2]=i; } b=a; sort(all(a),[](auto& i, auto& j){return i[0]>j[0];}); sort(all(b),[](auto& i, auto& j){return i[1]>j[1];}); pair<double,double> ans={0,0}; int j=-1; double x=0,y=0; F0R(i,n){ x+=a[i][0]; if(j+1<n&&min(x-(j+2),y+b[j+1][1]-(i+1))>min(ans.f,ans.s)){ ans={x-(j+2),y+b[j+1][1]-(i+1)}; y+=b[++j][1]; } else if(j>=0&&min(x-j,y-b[j][1]-(i+1))>min(ans.f,ans.s)){ ans={x-j,y-b[j][1]-(i+1)}; y-=b[j--][1]; } } cout<<fixed<<setprecision(4)<<min(ans.f,ans.s)<<nl; } int32_t main(){ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int TC = 1; // cin >> TC; while(TC--){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...