Submission #803467

# Submission time Handle Problem Language Result Execution time Memory
803467 2023-08-03T04:33:57 Z raysh07 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
58 ms 31156 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){
    vector <int> v;
    v.push_back(0);
    
    for (auto x : a){
        vector <int> nv;
        
        int p1 = 0;
        
        for (auto y : v){
            while (v[p1] + x < y){
                nv.push_back(v[p1] + x);
                p1++;
            } 
            
            nv.push_back(y);
        }
        
        while (p1 != v.size()){
            nv.push_back(v[p1] + x);
            p1++;
        }
        
        v = nv;
    }
    return v;
}
 
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 'std::vector<long long int> gen(std::vector<long long int>)':
bobek.cpp:28:19: 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]
   28 |         while (p1 != v.size()){
      |                ~~~^~~~~~~~~~~
bobek.cpp: In function 'void Solve()':
bobek.cpp:62: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]
   62 |         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 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4040 KB Output is correct
2 Correct 2 ms 1740 KB Output is correct
3 Correct 4 ms 3992 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 1740 KB Output is correct
6 Correct 28 ms 20976 KB Output is correct
7 Correct 3 ms 4040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 20984 KB Output is correct
2 Correct 7 ms 5552 KB Output is correct
3 Correct 2 ms 1740 KB Output is correct
4 Correct 2 ms 1856 KB Output is correct
5 Correct 22 ms 21044 KB Output is correct
6 Correct 5 ms 4040 KB Output is correct
7 Correct 4 ms 4080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 20964 KB Output is correct
2 Correct 29 ms 21080 KB Output is correct
3 Correct 55 ms 31072 KB Output is correct
4 Correct 28 ms 21000 KB Output is correct
5 Correct 19 ms 21044 KB Output is correct
6 Correct 22 ms 21004 KB Output is correct
7 Correct 26 ms 20924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 21044 KB Output is correct
2 Correct 27 ms 20964 KB Output is correct
3 Correct 29 ms 21032 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 18 ms 20960 KB Output is correct
6 Correct 24 ms 21032 KB Output is correct
7 Correct 27 ms 20928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 20968 KB Output is correct
2 Correct 28 ms 21044 KB Output is correct
3 Correct 30 ms 21036 KB Output is correct
4 Correct 6 ms 5572 KB Output is correct
5 Correct 23 ms 21052 KB Output is correct
6 Correct 36 ms 31100 KB Output is correct
7 Correct 33 ms 20932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 22912 KB Output is correct
2 Correct 28 ms 21008 KB Output is correct
3 Correct 30 ms 21044 KB Output is correct
4 Correct 1 ms 976 KB Output is correct
5 Correct 18 ms 21040 KB Output is correct
6 Correct 48 ms 22912 KB Output is correct
7 Correct 27 ms 21000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 20988 KB Output is correct
2 Correct 37 ms 20936 KB Output is correct
3 Correct 36 ms 21044 KB Output is correct
4 Correct 26 ms 21040 KB Output is correct
5 Correct 20 ms 20948 KB Output is correct
6 Correct 27 ms 20948 KB Output is correct
7 Correct 44 ms 31040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 31156 KB Output is correct
2 Correct 32 ms 20924 KB Output is correct
3 Correct 27 ms 20956 KB Output is correct
4 Correct 58 ms 31108 KB Output is correct
5 Correct 24 ms 21056 KB Output is correct
6 Correct 31 ms 20868 KB Output is correct
7 Correct 34 ms 20888 KB Output is correct