답안 #316765

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
316765 2020-10-28T00:03:08 Z LifeHappen__ Sure Bet (CEOI17_sure) C++14
100 / 100
95 ms 5244 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define forinc(a,b,c) for(int a=b, _c=c; a<=_c; ++a)
#define fordec(a,b,c) for(int a=b, _c=c; a>=_c; --a)
#define forv(a,b) for(auto &a:b)
#define fasty ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ar array
#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define reset(f,x) memset(f,x,sizeof(f))
#define bit(x,i) (x>>(i-1)&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))

const int N=1e5+5;
int n;
double a[N],b[N],x[N],y[N];

int32_t main(){
   fasty;

   cin>>n;
   forinc(i,1,n) cin>>a[i]>>b[i];
   sort(a+1, a+n+1); reverse(a+1, a+n+1);
   sort(b+1, b+n+1); reverse(b+1, b+n+1);
   forinc(i,1,n){
      x[i]=x[i-1]+a[i];
      y[i]=y[i-1]+b[i];
   }
   double ans=0;
   for(int i=1, j=1; i<=n; ++i){
      while(j<n && y[j]<x[i]) j++;
      ans=max(ans, min(y[j],x[i])-i-j);
   }
   for(int i=1, j=1; i<=n; ++i){
      while(j<n && x[j]<y[i]) j++;
      ans=max(ans, min(y[i],x[j])-i-j);
   }
   cout<<setprecision(4)<<fixed<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 416 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 416 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 87 ms 4856 KB Output is correct
18 Correct 89 ms 4860 KB Output is correct
19 Correct 88 ms 4776 KB Output is correct
20 Correct 89 ms 4856 KB Output is correct
21 Correct 94 ms 5240 KB Output is correct
22 Correct 86 ms 4856 KB Output is correct
23 Correct 86 ms 4856 KB Output is correct
24 Correct 86 ms 4880 KB Output is correct
25 Correct 87 ms 4872 KB Output is correct
26 Correct 95 ms 5244 KB Output is correct