답안 #313333

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
313333 2020-10-15T19:27:04 Z mohamedsobhi777 Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 384 KB
#include<bits/stdc++.h>


#pragma GCC optimize("-Ofast")
//#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")

#define I inline void 
#define S struct 
#define vi vector<int> 
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std ; 
using ll = long long ; 
using ld = long double ; 

const int N = 2e5 + 7 , mod = 1e9 + 7 ; 
const ll inf = 2e18 ; 

// How interesting!

int n ; 
vector<double> d[2] ; 
double ans ; 

void solve(){
        double pref = 0.0 ; 
        for(int i = 0 ; i < n; ++ i){
                pref += d[0][i] ; 
                double sum = 0 ; 
                for(int j = 0 ;j < n ; ++ j){
                        sum += d[1][j] -1.0; 
                        if(sum < pref)continue ; 
                        ans = max(ans , pref - double(j + 1) ) ; 
                }
        }
}

int main(){
        ios_base::sync_with_stdio(0) ;
        cin.tie(0) ; 
        //freopen("in.in" , "r" , stdin) ; 
        cin >> n; 
        for(int i = 0 ;i < n; ++ i){
                double a , b; 
                cin >> a >> b ;
                a-=1.0 ; b-=1.0 ; 
                d[0].push_back(a) ; 
                d[1].push_back(b) ; 
        }
        for(int i = 0 ;i < 2 ; ++ i)
                sort(d[i].begin() , d[i].end(), greater<double>()) ; 

        solve() ; 
        swap(d[0] , d[1]) ; 
        solve() ; 
        cout<< fixed <<setprecision(4) << ans ;
        return 0 ; 
}

/*
        - bounds sir (segtree = 4N, eulerTour = 2N, ...)
        - a variable defined twice?
        - will overflow?
        - is it a good complexity?
        - don't mess up indices (0-indexed vs 1-indexed)
        - reset everything between testcases. 
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -