Submission #1046139

# Submission time Handle Problem Language Result Execution time Memory
1046139 2024-08-06T10:29:50 Z ByeWorld Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
233 ms 33304 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define int long long
#define ll long long
#define pb push_back
#define fi first
#define se second
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
#define ld long double
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> ipii;
typedef pair<ld,ld> pll;
const int MAXN = 3e5+15;
const int INF = 3e18+10;
const int MX = 2e18;
void chmn(int &a, int b){ a = min(a, b); }
void chmx(int &a, int b){ a = max(a, b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, m;
int a[45];

signed main(){
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for(int i=1; i<=n; i++) cin >> a[i];
    vector <int> fr, sc; fr.pb(0); sc.pb(0);
    for(int i=1; i<=n/2; i++){
        vector <int> vec;
        for(auto in : fr){
            vec.pb(in);
            if(in+a[i] <= m) vec.pb(in+a[i]);
        }
        swap(vec, fr);
    }
    for(int i=n/2+1; i<=n; i++){
        vector <int> vec;
        for(auto in : sc){
            vec.pb(in);
            if(in+a[i] <= m) vec.pb(in+a[i]);
        }
        swap(vec, sc);
    }
    sort(sc.begin(), sc.end());
    // for(auto in : sc) cout << in << ' ';
    //     cout << "sc\n";

    int ans = 0;
    for(auto in : fr){
        // cout << in << " in\n";
        // cout << upper_bound(sc.begin(), sc.end(), m-in)-sc.begin()-1 << '\n';
        int te = (int)(upper_bound(sc.begin(), sc.end(), m-in)-sc.begin());
        ans += te;
    }
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 2648 KB Output is correct
2 Correct 48 ms 8592 KB Output is correct
3 Correct 233 ms 33304 KB Output is correct
4 Correct 47 ms 8516 KB Output is correct
5 Correct 4 ms 2388 KB Output is correct
6 Correct 2 ms 1244 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 4556 KB Output is correct
2 Correct 14 ms 2648 KB Output is correct
3 Correct 95 ms 16828 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 2 ms 1244 KB Output is correct
6 Correct 5 ms 2388 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 4556 KB Output is correct
2 Correct 64 ms 10308 KB Output is correct
3 Correct 70 ms 10060 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 26 ms 9448 KB Output is correct
6 Correct 82 ms 33072 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 156 ms 17380 KB Output is correct
2 Correct 16 ms 2648 KB Output is correct
3 Correct 5 ms 1336 KB Output is correct
4 Correct 0 ms 408 KB Output is correct
5 Correct 2 ms 1244 KB Output is correct
6 Correct 82 ms 18016 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2648 KB Output is correct
2 Correct 53 ms 8516 KB Output is correct
3 Correct 4 ms 1244 KB Output is correct
4 Correct 4 ms 1244 KB Output is correct
5 Correct 27 ms 10176 KB Output is correct
6 Correct 10 ms 2648 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 174 ms 33048 KB Output is correct
2 Correct 16 ms 2648 KB Output is correct
3 Correct 4 ms 1244 KB Output is correct
4 Correct 225 ms 33056 KB Output is correct
5 Correct 37 ms 16824 KB Output is correct
6 Correct 6 ms 2640 KB Output is correct
7 Correct 0 ms 348 KB Output is correct