답안 #630804

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
630804 2022-08-17T06:36:19 Z Do_you_copy Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
229 ms 16744 KB
#include <bits/stdc++.h>
//#define int long long
#define fi first
#define se second
#define pb push_back
#define faster ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
using ll = long long;
using ull = unsigned ll;
using ld = long double;
using pii = pair <int, int>;
using pil = pair <int, ll>;
using pli = pair <ll, int>;
using pll = pair <ll, ll>;
mt19937 Rand(chrono::steady_clock::now().time_since_epoch().count());

ll min(const ll &a, const ll &b){
    return (a < b) ? a : b;
}

ll max(const ll &a, const ll &b){
    return (a > b) ? a : b;
}

//const ll Mod = 1000000007;
//const ll Mod2 = 999999999989;
//only use when required
const int maxN = 40 + 1;
int n;
ll B;
ll a[maxN];
ll l[1 << 21];
ll r[1 << 21];

void Init(){
    cin >> n >> B;
    for (int i = 1; i <= n; ++i){
        cin >> a[i];
    }
    int k = n / 2;
    for (int mask = 1; mask < 1 << k; ++mask){
        l[mask] = l[mask - (mask & -mask)] + a[__lg(mask & -mask) + 1];
    }
    for (int mask = 1; mask < 1 << (n - k); ++mask){
        r[mask] = r[mask - (mask & -mask)] + a[__lg(mask & -mask) + k + 1];
    }
    sort(l, l + (1 << k));
    sort(r, r + (1 << (n - k)));
    ll ans = 0;
    for (int i = 0; i < 1 << k; ++i){
        int j = upper_bound(r, r + (1 << (n - k)), B - l[i]) - r;
        ans += j;
    }
    cout << ans;
}

#define debu
#define taskname "test"
signed main(){
    if (fopen(taskname".inp", "r")){
        freopen(taskname".inp", "r", stdin);
        #ifdef debug
        freopen(taskname".out", "w", stdout);
        #endif
    }
    faster;
    ll tt = 1;
    //cin >> tt;
    while (tt--){
        Init();
    }
    if (fopen("timeout.txt", "r")){
        ofstream timeout("timeout.txt");
        timeout << 1000 * double(clock()) / CLOCKS_PER_SEC;
        #ifndef debug
        cerr << "\nTime elapsed: " << 1000 * double(clock()) / CLOCKS_PER_SEC << "ms\n";
        #endif
    }
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:61:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 1868 KB Output is correct
2 Correct 51 ms 4436 KB Output is correct
3 Correct 229 ms 16736 KB Output is correct
4 Correct 49 ms 4536 KB Output is correct
5 Correct 6 ms 1364 KB Output is correct
6 Correct 5 ms 852 KB Output is correct
7 Correct 10 ms 1380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 2400 KB Output is correct
2 Correct 17 ms 1876 KB Output is correct
3 Correct 73 ms 8532 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 852 KB Output is correct
6 Correct 11 ms 1364 KB Output is correct
7 Correct 10 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 3412 KB Output is correct
2 Correct 77 ms 6492 KB Output is correct
3 Correct 79 ms 6484 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 30 ms 6488 KB Output is correct
6 Correct 173 ms 16672 KB Output is correct
7 Correct 67 ms 6476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 160 ms 12632 KB Output is correct
2 Correct 17 ms 1884 KB Output is correct
3 Correct 7 ms 852 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 3 ms 840 KB Output is correct
6 Correct 142 ms 12736 KB Output is correct
7 Correct 11 ms 1364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 1876 KB Output is correct
2 Correct 50 ms 4432 KB Output is correct
3 Correct 7 ms 852 KB Output is correct
4 Correct 6 ms 844 KB Output is correct
5 Correct 39 ms 6452 KB Output is correct
6 Correct 15 ms 1876 KB Output is correct
7 Correct 200 ms 16720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 203 ms 16740 KB Output is correct
2 Correct 19 ms 1876 KB Output is correct
3 Correct 6 ms 852 KB Output is correct
4 Correct 217 ms 16744 KB Output is correct
5 Correct 47 ms 8532 KB Output is correct
6 Correct 10 ms 1364 KB Output is correct
7 Correct 27 ms 2388 KB Output is correct