Submission #53083

# Submission time Handle Problem Language Result Execution time Memory
53083 2018-06-28T08:06:47 Z Alexa2001 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
413 ms 21504 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int Nmax = 100;

ll a[Nmax], b[Nmax], ans = 0, sum, money;
vector<ll> A, B;
int i, j, n, m;

int main()
{
  //  freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    cin >> n >> money;
    m = n>>1; n -= m;
    for(i=0; i<n; ++i) cin >> a[i];
    for(i=0; i<m; ++i) cin >> b[i];

    for(i=0; i<(1<<n); ++i)
    {
        sum = 0;
        for(j=0; j<n; ++j)
            if(i & (1<<j)) sum += a[j];
        A.push_back(sum);
    }

    for(i=0; i<(1<<m); ++i)
    {
        sum = 0;
        for(j=0; j<m; ++j)
            if(i & (1<<j)) sum += b[j];
        B.push_back(sum);
    }

    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    sort(B.begin(), B.end());

    j = 0;
    for(i=0; i<A.size(); ++i)
    {
        while(j<B.size() && A[i] + B[j] <= money) ++j;
        ans += j;
    }

    cout << ans << '\n';
    return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:44:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0; i<A.size(); ++i)
              ~^~~~~~~~~
bobek.cpp:46:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(j<B.size() && A[i] + B[j] <= money) ++j;
               ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 484 KB Output is correct
2 Correct 2 ms 500 KB Output is correct
3 Correct 2 ms 500 KB Output is correct
4 Correct 2 ms 584 KB Output is correct
5 Correct 2 ms 584 KB Output is correct
6 Correct 2 ms 620 KB Output is correct
7 Correct 2 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
3 Correct 3 ms 740 KB Output is correct
4 Correct 2 ms 884 KB Output is correct
5 Correct 2 ms 884 KB Output is correct
6 Correct 2 ms 884 KB Output is correct
7 Correct 2 ms 884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 884 KB Output is correct
2 Correct 2 ms 884 KB Output is correct
3 Correct 3 ms 884 KB Output is correct
4 Correct 2 ms 884 KB Output is correct
5 Correct 3 ms 884 KB Output is correct
6 Correct 2 ms 884 KB Output is correct
7 Correct 2 ms 884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 2788 KB Output is correct
2 Correct 98 ms 5852 KB Output is correct
3 Correct 413 ms 21216 KB Output is correct
4 Correct 96 ms 21216 KB Output is correct
5 Correct 17 ms 21216 KB Output is correct
6 Correct 11 ms 21216 KB Output is correct
7 Correct 22 ms 21216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 21216 KB Output is correct
2 Correct 33 ms 21216 KB Output is correct
3 Correct 174 ms 21216 KB Output is correct
4 Correct 2 ms 21216 KB Output is correct
5 Correct 9 ms 21216 KB Output is correct
6 Correct 22 ms 21216 KB Output is correct
7 Correct 22 ms 21216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 21216 KB Output is correct
2 Correct 144 ms 21216 KB Output is correct
3 Correct 142 ms 21216 KB Output is correct
4 Correct 2 ms 21216 KB Output is correct
5 Correct 104 ms 21216 KB Output is correct
6 Correct 338 ms 21436 KB Output is correct
7 Correct 139 ms 21436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 291 ms 21436 KB Output is correct
2 Correct 37 ms 21436 KB Output is correct
3 Correct 12 ms 21436 KB Output is correct
4 Correct 2 ms 21436 KB Output is correct
5 Correct 10 ms 21436 KB Output is correct
6 Correct 288 ms 21436 KB Output is correct
7 Correct 22 ms 21436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 21436 KB Output is correct
2 Correct 91 ms 21436 KB Output is correct
3 Correct 12 ms 21436 KB Output is correct
4 Correct 13 ms 21436 KB Output is correct
5 Correct 121 ms 21436 KB Output is correct
6 Correct 33 ms 21436 KB Output is correct
7 Correct 382 ms 21436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 409 ms 21436 KB Output is correct
2 Correct 34 ms 21436 KB Output is correct
3 Correct 12 ms 21436 KB Output is correct
4 Correct 399 ms 21504 KB Output is correct
5 Correct 133 ms 21504 KB Output is correct
6 Correct 22 ms 21504 KB Output is correct
7 Correct 44 ms 21504 KB Output is correct