Submission #759212

# Submission time Handle Problem Language Result Execution time Memory
759212 2023-06-15T21:13:16 Z sofija6 Ice Hockey World Championship (CEOI15_bobek) C++14
60 / 100
1000 ms 166768 KB
#include <bits/stdc++.h>
#define ll long long
#define MAXN 50
using namespace std;
ll a[MAXN],m;
set<ll> s1,s2;
map<ll,ll> cnt1,cnt2;
void Solve(ll l,ll r,ll cur,ll pos,set<ll> &s,map<ll,ll> &cnt)
{
    if (pos>r)
    {
        if (cur>m)
            return;
        s.insert(cur);
        cnt[cur]++;
        return;
    }
    Solve(l,r,cur,pos+1,s,cnt);
    Solve(l,r,cur+a[pos],pos+1,s,cnt);
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n,ans=0;
    cin >> n >> m;
    for (ll i=1;i<=n;i++)
        cin >> a[i];
    Solve(1,n/2,0,1,s1,cnt1);
    Solve(n/2+1,n,0,n/2+1,s2,cnt2);
    ll cur=0;
    for (auto i : s2)
    {
        cur+=cnt2[i];
        cnt2[i]=cur;
    }
    for (auto i : s1)
    {
        auto it=s2.lower_bound(m-i);
        if ((*it)!=m-i)
        {
            if (it==s2.begin())
                continue;
            it--;
        }
        ans+=cnt1[i]*cnt2[*it];
    }
    cout << ans;
    return 0;
}
# 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 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 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 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 384 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 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 2920 KB Output is correct
2 Correct 390 ms 38376 KB Output is correct
3 Execution timed out 1075 ms 92448 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 61 ms 4940 KB Output is correct
2 Correct 87 ms 13840 KB Output is correct
3 Correct 154 ms 2396 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Correct 38 ms 5952 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 273 ms 31296 KB Output is correct
2 Correct 378 ms 32208 KB Output is correct
3 Correct 388 ms 30840 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Incorrect 18 ms 324 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 166768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 157 ms 21840 KB Output is correct
2 Correct 497 ms 57756 KB Output is correct
3 Correct 31 ms 7376 KB Output is correct
4 Correct 30 ms 7364 KB Output is correct
5 Correct 25 ms 332 KB Output is correct
6 Correct 136 ms 21732 KB Output is correct
7 Correct 14 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1050 ms 158124 KB Time limit exceeded
2 Halted 0 ms 0 KB -