답안 #1110449

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1110449 2024-11-09T13:16:18 Z guymmk Ice Hockey World Championship (CEOI15_bobek) C++14
40 / 100
1000 ms 166540 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize("O3,Ofast,unroll-loops")
//#pragma GCC target("popcnt")
#define int long long
#define ll long long
#define ld long double
#define endl '\n'
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define debug(...) printf(__VA_ARGS__)
//#define debug(...)
#define trace(x) cout<<#x<<"="<<x<<endl;
//#define trace(x)
#define vi vector<int>
#define popcnt(x) (int)__builtin_popcountll(x)
#define vpii vector<pii >
#define vaii vector<array<int,2>>
#define vvi vector<vector<int> >
#define umap unordered_map
#define uset unordered_set
#define mk make_pair
#define pb push_back
#define pob pop_back
#define _ <<' '<<
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define read(x) for (auto& zu: (x)) cin >> zu;
#define write(x) for (auto& zu: (x))cout << zu<<' '; cout<<endl;
static inline void print(const int &x) {
    if (x > 9)print(x / 10);
    putchar('0' + x % 10);
}
//template<typename... T>void read(T&... args) {((for (auto &zu: (args)) { cin >> zu; }),...);}
#define F first
#define S second
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define mustawa ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie();
#define saudi main
const int inf=1e9+7;
void fa(bool ok){ cout << (ok ? "YES": "NO") << endl;}
int pw(ll a, ll b, ll mod= 1e9 + 7){
    a %= mod;
    ll res = 1;
    while (b > 0) {
        if (b % 2 == 1) {
            res = res * a%mod;
        }b /= 2;
        a = a * a%mod;
    }
    return res;
}
inline void usaco(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}inline void usaco(string s1,string s2) {
    freopen((s1 + ".txt").c_str(), "r", stdin);
    freopen((s2 + ".txt").c_str(), "w", stdout);
    freopen("err.txt", "w", stderr);
}int inve(int x,int mod=inf){
    return pow(x,mod-2);
}
int gcd(int a,int b){
    if (b == 0)return a;
    return gcd(b, a % b);
}

int lcm(int a, int b){
    return (a / gcd(a, b)) * b;
}
//long double log(int base,int x){
//    return log2(x)/log(base);
//}
int log(int base,int x){
    return (int)(log2(x)/log2(base));
}
int sum(int l,int r) {
    if (l > r)swap(l, r);
    int a = ((l - 1) * (l)) / 2;
    int b = (r * (r + 1)) / 2;
    return b - a;
}multiset<int>ms1,ms2,ans;
int n,x;
vi v;
void f1(int i,int sum){
    if(i==(n+1)/2)return;
    f1(i+1,sum);
    if(sum+v[i]<=x){
        f1(i+1,sum+v[i]);
        ms1.insert(sum+v[i]);
    }
}void f2(int i,int sum){
    if(i==n)return;
    f2(i+1,sum);
    if(sum+v[i]<=x){
        f2(i+1,sum+v[i]);
        ms2.insert(sum+v[i]);
    }
}
void solve() {
    cin>>n>>x;
    v.resize(n);
    read(v);
    f1(0,0);
    f2((n+1)/2,0);
    if(ms1.size()<ms2.size())swap(ms1,ms2);
    for(auto i:ms1)ans.insert(i);
    for(auto i:ms2)ans.insert(i);
    for(auto i:ms1){
        for(auto j:ms2){
            if(i+j<=x)ans.insert(i+j);
            else break;
        }
    }
    cout<<ans.size()+1<<endl;
}

signed saudi() {
    mustawa;
    // usaco("pow");
//#ifndef ONLINE_JUDGE
//    usaco("input","output");
//#endif
    int tescases=1;
    //cin>>tescases;
    for (int i = 1; i <= tescases; i++) {
        //cout<<"Case #"<<i<<":"<<' ';
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 3664 KB Output is correct
2 Correct 7 ms 1872 KB Output is correct
3 Correct 16 ms 3408 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 9 ms 2732 KB Output is correct
6 Correct 516 ms 49648 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 450 ms 36928 KB Output is correct
2 Correct 18 ms 3408 KB Output is correct
3 Correct 13 ms 2640 KB Output is correct
4 Correct 3 ms 1104 KB Output is correct
5 Correct 88 ms 17500 KB Output is correct
6 Correct 31 ms 6480 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1067 ms 166540 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1077 ms 163668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1068 ms 146968 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1069 ms 136716 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 130156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1067 ms 106552 KB Time limit exceeded
2 Halted 0 ms 0 KB -