Submission #867390

# Submission time Handle Problem Language Result Execution time Memory
867390 2023-10-28T10:14:12 Z Muhammad_Aneeq Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
363 ms 16860 KB
/*
بسم الله الرحمن الرحيم
Author:
                          (:Muhammad Aneeq:)
*/
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define int long long
inline void solve()
{
  int n,K;
  cin>>n>>K;
  int a[n];
  for (auto& i:a)
    cin>>i;
  vector<int>x((1<<(n/2))),y(1<<(n-n/2));
  for (int i=0;i<=x.size();++i)
  {
    int z=0;
    for (int j=0;j<n/2;j++)
    {
      if ((1<<j)&i)
        z+=a[j];
    }
    x[i]=z;
  }
  for (int i=0;i<=y.size();i++)
  {
    int z=0;
    for (int j=0;j<n-n/2;j++)
    {
      if ((1<<j)&i)
        z+=a[n/2+j];
    }
    y[i]=z;
  } 
  sort(x.begin(), x.end());
  int ans=0;
  for (auto i:y)
  {
    int z=upper_bound(x.begin(), x.end(),K-i)-begin(x);
    ans+=z;
  }
  cout<<ans<<endl;
}
signed main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
        solve();
}

Compilation message

bobek.cpp: In function 'void solve()':
bobek.cpp:22:17: 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]
   22 |   for (int i=0;i<=x.size();++i)
      |                ~^~~~~~~~~~
bobek.cpp:32:17: 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]
   32 |   for (int i=0;i<=y.size();i++)
      |                ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2012 KB Output is correct
2 Correct 68 ms 4552 KB Output is correct
3 Correct 332 ms 16732 KB Output is correct
4 Correct 67 ms 4444 KB Output is correct
5 Correct 8 ms 1368 KB Output is correct
6 Correct 4 ms 980 KB Output is correct
7 Correct 8 ms 1500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 2396 KB Output is correct
2 Correct 22 ms 2008 KB Output is correct
3 Correct 144 ms 8656 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 4 ms 860 KB Output is correct
6 Correct 8 ms 1372 KB Output is correct
7 Correct 8 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 3536 KB Output is correct
2 Correct 113 ms 6600 KB Output is correct
3 Correct 101 ms 6600 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 40 ms 6620 KB Output is correct
6 Correct 138 ms 16728 KB Output is correct
7 Correct 48 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 249 ms 12756 KB Output is correct
2 Correct 18 ms 1884 KB Output is correct
3 Correct 6 ms 860 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 4 ms 860 KB Output is correct
6 Correct 93 ms 12764 KB Output is correct
7 Correct 8 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 2256 KB Output is correct
2 Correct 61 ms 4444 KB Output is correct
3 Correct 5 ms 856 KB Output is correct
4 Correct 6 ms 984 KB Output is correct
5 Correct 45 ms 6492 KB Output is correct
6 Correct 10 ms 1884 KB Output is correct
7 Correct 160 ms 16732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 279 ms 16860 KB Output is correct
2 Correct 21 ms 1880 KB Output is correct
3 Correct 6 ms 860 KB Output is correct
4 Correct 363 ms 16860 KB Output is correct
5 Correct 80 ms 8536 KB Output is correct
6 Correct 8 ms 1372 KB Output is correct
7 Correct 17 ms 2520 KB Output is correct