답안 #246470

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
246470 2020-07-09T11:39:16 Z uacoder123 Sure Bet (CEOI17_sure) C++14
100 / 100
118 ms 3616 KB
     #include <bits/stdc++.h>
    using namespace std;
    #define F first
    #define S second
    #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
    #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
    #define all(x) (x).begin(), (x).end()
    #define sz(x) int(x.size())
    #define mp(i,a) make_pair(i,a)
    #define pb(a) push_back(a)
    #define bit(x,b) (x&(1LL<<b))
     
    typedef long long int lli;
    typedef pair <lli,lli> ii;
    typedef pair <lli,ii> iii;
    typedef vector <lli> vi;
     
    int main()
    {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int test=1;
      for(;test>0;--test)
      {
        lli n;
        double ans=0;
        cin>>n;
        int k=-1;
        vector<double> f(n),s(n);
        for(int i=0;i<n;++i)
          cin>>f[i]>>s[i];
        sort(all(f),greater<double>());
        sort(all(s),greater<double>());
        if(k==-1&&s[0]<1)
            k=0;
        for(int i=1;i<n;++i)
        {
          if(k==-1&&s[i]<1)
            k=i;
          f[i]=f[i]+f[i-1];
          s[i]=s[i]+s[i-1];
        }
        if(k==-1)
            k=n-1;
        for(int i=0;i<n;++i)
        {
          lli j=lower_bound(all(s),f[i])-s.begin();
          ans=max(ans,min(f[i]-i-1-min(n-1,j)-1,s[min(j,n-1)]-i-1-min(j,n-1)-1));
          j=min(j-1,k*1LL);
          ans=max(ans,min(f[i]-i-1-j-1,s[j]-i-1-j-1));
        }
        cout<<fixed<<setprecision(4)<<ans<<endl;
      }
      return(0);
    }
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 105 ms 3320 KB Output is correct
18 Correct 117 ms 3320 KB Output is correct
19 Correct 106 ms 3320 KB Output is correct
20 Correct 109 ms 3320 KB Output is correct
21 Correct 118 ms 3616 KB Output is correct
22 Correct 106 ms 3228 KB Output is correct
23 Correct 104 ms 3324 KB Output is correct
24 Correct 106 ms 3448 KB Output is correct
25 Correct 103 ms 3320 KB Output is correct
26 Correct 116 ms 3576 KB Output is correct