Submission #738632

# Submission time Handle Problem Language Result Execution time Memory
738632 2023-05-09T09:02:34 Z bgnbvnbv Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
305 ms 20840 KB
#include<bits/stdc++.h>
#define TASKNAME "codeforce"
#define pb push_back
#define pli pair<int,int>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxN=2e5;
const ll inf=1e18;
const ll mod=1e9+7;
ll n,m,a[maxN];
vector<ll>vec1,vec2;
void solve()
{
    cin >> n >> m;ll ans=0;
    for(int i=1;i<=n;i++) cin >> a[i];
    ll k=n/2;
    for(int mask=0;mask<(1<<k);mask++)
    {
        ll sum=0;
        for(int i=0;i<k;i++)
        {
            if(mask>>i&1)
            {
                sum+=a[i+1];
            }
        }
        vec1.pb(sum);
    }
    for(int mask=0;mask<(1<<(n-k));mask++)
    {
        ll sum=0;
        for(int i=0;i<n-k;i++)
        {
            if(mask>>i&1)
            {
                sum+=a[i+k+1];
            }
        }
        vec2.pb(sum);
    }
    sort(vec1.begin(),vec1.end());
    sort(vec2.begin(),vec2.end());
    ll j=0;
    for(int i=vec1.size()-1;i>=0;i--)
    {
        while(j<vec2.size()&&vec2[j]+vec1[i]<=m) j++;
        ans+=j;
    }
    cout << ans;
}
int main()
{
    fastio
    //freopen(TASKNAME".INP","r",stdin);
    //freopen(TASKNAME".OUT","w",stdout);
    solve();
}

Compilation message

bobek.cpp: In function 'void solve()':
bobek.cpp:49:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         while(j<vec2.size()&&vec2[j]+vec1[i]<=m) j++;
      |               ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory 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 328 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1992 KB Output is correct
2 Correct 73 ms 5480 KB Output is correct
3 Correct 305 ms 20752 KB Output is correct
4 Correct 72 ms 5452 KB Output is correct
5 Correct 12 ms 1620 KB Output is correct
6 Correct 9 ms 968 KB Output is correct
7 Correct 16 ms 1620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 2816 KB Output is correct
2 Correct 27 ms 2008 KB Output is correct
3 Correct 126 ms 10568 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 6 ms 984 KB Output is correct
6 Correct 17 ms 1544 KB Output is correct
7 Correct 16 ms 1620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 3492 KB Output is correct
2 Correct 109 ms 6596 KB Output is correct
3 Correct 110 ms 6604 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 77 ms 6584 KB Output is correct
6 Correct 262 ms 20776 KB Output is correct
7 Correct 103 ms 6516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 220 ms 12828 KB Output is correct
2 Correct 26 ms 1996 KB Output is correct
3 Correct 9 ms 984 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 7 ms 984 KB Output is correct
6 Correct 218 ms 12808 KB Output is correct
7 Correct 16 ms 1620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2008 KB Output is correct
2 Correct 71 ms 5460 KB Output is correct
3 Correct 8 ms 984 KB Output is correct
4 Correct 8 ms 984 KB Output is correct
5 Correct 77 ms 6592 KB Output is correct
6 Correct 26 ms 2008 KB Output is correct
7 Correct 286 ms 20756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 296 ms 20840 KB Output is correct
2 Correct 25 ms 2012 KB Output is correct
3 Correct 9 ms 968 KB Output is correct
4 Correct 300 ms 20728 KB Output is correct
5 Correct 106 ms 10508 KB Output is correct
6 Correct 16 ms 1620 KB Output is correct
7 Correct 34 ms 2900 KB Output is correct