Submission #759213

# Submission time Handle Problem Language Result Execution time Memory
759213 2023-06-15T21:15:53 Z sofija6 Ice Hockey World Championship (CEOI15_bobek) C++14
60 / 100
1000 ms 161152 KB
#include <bits/stdc++.h>
#define ll long long
#define MAXN 50
using namespace std;
ll a[MAXN],m,l,r;
set<ll> s1,s2;
map<ll,ll> cnt1,cnt2;
void Solve_1(ll cur,ll pos)
{
    if (pos>r)
    {
        if (cur>m)
            return;
        s1.insert(cur);
        cnt1[cur]++;
        return;
    }
    Solve_1(cur,pos+1);
    Solve_1(cur+a[pos],pos+1);
}
void Solve_2(ll cur,ll pos)
{
    if (pos>r)
    {
        if (cur>m)
            return;
        s2.insert(cur);
        cnt2[cur]++;
        return;
    }
    Solve_2(cur,pos+1);
    Solve_2(cur+a[pos],pos+1);
}
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];
    l=1;
    r=n/2;
    Solve_1(0,1);
    l=n/2+1;
    r=n;
    Solve_2(0,n/2+1);
    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 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 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 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 0 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 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 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 2900 KB Output is correct
2 Correct 364 ms 38256 KB Output is correct
3 Execution timed out 1085 ms 90064 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 62 ms 5000 KB Output is correct
2 Correct 101 ms 13840 KB Output is correct
3 Correct 152 ms 2380 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 2 ms 316 KB Output is correct
6 Correct 44 ms 5836 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 326 ms 31372 KB Output is correct
2 Correct 413 ms 32108 KB Output is correct
3 Correct 393 ms 30840 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Incorrect 18 ms 316 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 161152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 150 ms 21844 KB Output is correct
2 Correct 531 ms 57708 KB Output is correct
3 Correct 37 ms 7392 KB Output is correct
4 Correct 36 ms 7320 KB Output is correct
5 Correct 25 ms 360 KB Output is correct
6 Correct 152 ms 21728 KB Output is correct
7 Correct 14 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 145880 KB Time limit exceeded
2 Halted 0 ms 0 KB -