Submission #498327

# Submission time Handle Problem Language Result Execution time Memory
498327 2021-12-25T04:09:32 Z kingline Sure Bet (CEOI17_sure) C++17
20 / 100
2000 ms 204 KB
/*#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,avx2,fma")
//#define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout);
#define pb push_back
//#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(data) data.begin() , data.end()
#define endl '\n'
//freopen("nenokku_easy.in", "r", stdin);
//freopen("nenokku_easy.out", "w", stdout);
#define int long long
#define pii pair < int, int >
#define pll pair < long long, long long >

using namespace std;

typedef long long ll;
const int N = 2e5 + 5;
const int M = 305;
const int mod = 1e9 + 7;

int n;
double a[N], b[N], ans;

void reca(int pos, int cnt, double sum) {
    for(int mask = 0; mask < (1 << n); mask++) {
        double sum1 = 0; int cnt1 = 0;
        for(int i = 0; i < n; i++) {
            if((mask >> i) & 1) {
                sum1 += b[i + 1];
                cnt1++;
            }
        }
        //cout << sum << " " << sum1 << " " << cnt << " " << cnt1 << endl;
        ans = max(ans, min(sum - cnt - cnt1, sum1 - cnt - cnt1));
    }
    if(pos == n) return;
    reca(pos + 1, cnt + 1, sum + a[pos + 1]);
    reca(pos + 1, cnt, sum);
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //file("pieaters");
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
    }
    reca(0, 0, 0);
    cout << fixed << setprecision(4) << ans;
}















Compilation message

sure.cpp:47:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   47 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 48 ms 204 KB Output is correct
4 Correct 48 ms 204 KB Output is correct
5 Correct 50 ms 204 KB Output is correct
6 Correct 48 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 48 ms 204 KB Output is correct
4 Correct 48 ms 204 KB Output is correct
5 Correct 50 ms 204 KB Output is correct
6 Correct 48 ms 204 KB Output is correct
7 Execution timed out 2077 ms 204 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 48 ms 204 KB Output is correct
4 Correct 48 ms 204 KB Output is correct
5 Correct 50 ms 204 KB Output is correct
6 Correct 48 ms 204 KB Output is correct
7 Execution timed out 2077 ms 204 KB Time limit exceeded
8 Halted 0 ms 0 KB -