Submission #759211

# Submission time Handle Problem Language Result Execution time Memory
759211 2023-06-15T21:11:10 Z sofija6 Ice Hockey World Championship (CEOI15_bobek) C++14
50 / 100
1000 ms 160320 KB
#include <bits/stdc++.h>
#define ll long long
#define MAXN 50
using namespace std;
ll a[MAXN];
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)
    {
        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,m,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 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 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 1 ms 316 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 456 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 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 2836 KB Output is correct
2 Correct 375 ms 38260 KB Output is correct
3 Execution timed out 1094 ms 90440 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 64 ms 4996 KB Output is correct
2 Correct 92 ms 13944 KB Output is correct
3 Correct 154 ms 2380 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
6 Correct 43 ms 5836 KB Output is correct
7 Correct 69 ms 14540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 284 ms 31396 KB Output is correct
2 Correct 433 ms 32176 KB Output is correct
3 Correct 390 ms 30748 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Incorrect 16 ms 328 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 160320 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 141 ms 21764 KB Output is correct
2 Correct 510 ms 57756 KB Output is correct
3 Correct 32 ms 7396 KB Output is correct
4 Correct 31 ms 7444 KB Output is correct
5 Correct 26 ms 332 KB Output is correct
6 Correct 150 ms 21768 KB Output is correct
7 Execution timed out 1079 ms 150172 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 155232 KB Time limit exceeded
2 Halted 0 ms 0 KB -