Submission #803413

# Submission time Handle Problem Language Result Execution time Memory
803413 2023-08-03T04:26:24 Z raysh07 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
194 ms 25004 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF (int)1e18
#define f first
#define s second
 
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
 
vector <int> gen(vector <int> a){
    
    if (a.size() == 0){
        vector <int> res;
        res.push_back(0);
        return res;
    }
    
    int x = a.back();
    a.pop_back();
    vector <int> v = gen(a);
    auto res = v;
    for (auto y : v){
        res.push_back(y + x);
    }
    
    return res;
}
 
void Solve() 
{
    int n, m; cin >> n >> m;
    
    vector <int> a, b;
    for (int i = 0; i < n; i++){
        int x; cin >> x;
        if (i < 20){
            a.push_back(x);
        } else {
            b.push_back(x);
        }
    }
    
    vector <int> v1 = gen(a);
    vector <int> v2 = gen(b);
    
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    int ptr = 0;
    int ans = 0;
    reverse(v1.begin(), v1.end());
    
    for (auto x : v1){
        while (ptr != v2.size() && x + v2[ptr] <= m){
            ptr++;
        }
        
        ans += ptr;
    }
    
    cout << ans << "\n";
}
 
int32_t main() 
{
    auto begin = std::chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
//    cin >> t;
    for(int i = 1; i <= t; i++) 
    {
        //cout << "Case #" << i << ": ";
        Solve();
    }
    auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 
    return 0;
}

Compilation message

bobek.cpp: In function 'void Solve()':
bobek.cpp:53:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         while (ptr != v2.size() && x + v2[ptr] <= m){
      |                ~~~~^~~~~~~~~~~~
# 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 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 328 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 11 ms 1976 KB Output is correct
2 Correct 5 ms 1236 KB Output is correct
3 Correct 12 ms 1992 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 5 ms 1216 KB Output is correct
6 Correct 85 ms 12756 KB Output is correct
7 Correct 10 ms 1992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 90 ms 12724 KB Output is correct
2 Correct 19 ms 3508 KB Output is correct
3 Correct 5 ms 1220 KB Output is correct
4 Correct 5 ms 1232 KB Output is correct
5 Correct 52 ms 12724 KB Output is correct
6 Correct 11 ms 1992 KB Output is correct
7 Correct 9 ms 1992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 12704 KB Output is correct
2 Correct 89 ms 12728 KB Output is correct
3 Correct 174 ms 24980 KB Output is correct
4 Correct 102 ms 12744 KB Output is correct
5 Correct 48 ms 12708 KB Output is correct
6 Correct 68 ms 12724 KB Output is correct
7 Correct 88 ms 12740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 12724 KB Output is correct
2 Correct 91 ms 12736 KB Output is correct
3 Correct 82 ms 12728 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 42 ms 12748 KB Output is correct
6 Correct 91 ms 12724 KB Output is correct
7 Correct 83 ms 12708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 12724 KB Output is correct
2 Correct 89 ms 12724 KB Output is correct
3 Correct 98 ms 12776 KB Output is correct
4 Correct 25 ms 3508 KB Output is correct
5 Correct 50 ms 12724 KB Output is correct
6 Correct 153 ms 24988 KB Output is correct
7 Correct 103 ms 12748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 140 ms 16748 KB Output is correct
2 Correct 85 ms 12780 KB Output is correct
3 Correct 85 ms 12724 KB Output is correct
4 Correct 3 ms 852 KB Output is correct
5 Correct 46 ms 12704 KB Output is correct
6 Correct 125 ms 16740 KB Output is correct
7 Correct 86 ms 12704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 88 ms 12724 KB Output is correct
2 Correct 96 ms 12704 KB Output is correct
3 Correct 93 ms 12688 KB Output is correct
4 Correct 91 ms 12724 KB Output is correct
5 Correct 53 ms 12848 KB Output is correct
6 Correct 92 ms 12724 KB Output is correct
7 Correct 161 ms 25004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 175 ms 24956 KB Output is correct
2 Correct 88 ms 12724 KB Output is correct
3 Correct 88 ms 12744 KB Output is correct
4 Correct 194 ms 24936 KB Output is correct
5 Correct 65 ms 12724 KB Output is correct
6 Correct 85 ms 12724 KB Output is correct
7 Correct 88 ms 12708 KB Output is correct