Submission #968530

#TimeUsernameProblemLanguageResultExecution timeMemory
968530vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
100 / 100
289 ms22192 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; using ll = long long; const int N = 44; ll n, m; vector<ll> lv, rv; vector<ll> la, ra; void calc(vector<ll> &v, vector<ll> &res){ for (int i = 0;i < (1<<v.size());i++){ ll sm = 0; for (int j = 0;j < v.size();j++){ if (i&(1<<j)) sm += v[j]; } res.push_back(sm); } sort(res.begin(), res.end()); } int main() { int n; ll k; scanf("%d %lld", &n, &k);; for (int i = 0;i < n/2;i++){ ll v; scanf("%lld", &v); la.push_back(v); } for (int i = n/2;i < n;i++){ ll v; scanf("%lld", &v); ra.push_back(v); } calc(la, lv); calc(ra, rv); ll p = 0ll, ans = 0ll; reverse(lv.begin(), lv.end()); for (auto e:lv){ while (p < rv.size() && rv[p]+e <= k) p++; ans += p; } printf("%lld", ans); }

Compilation message (stderr)

bobek.cpp: In function 'void calc(std::vector<long long int>&, std::vector<long long int>&)':
bobek.cpp:16:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         for (int j = 0;j < v.size();j++){
      |                        ~~^~~~~~~~~~
bobek.cpp: In function 'int main()':
bobek.cpp:41:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         while (p < rv.size() && rv[p]+e <= k) p++;
      |                ~~^~~~~~~~~~~
bobek.cpp:27:16: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     ll k; scanf("%d %lld", &n, &k);;
      |           ~~~~~^~~~~~~~~~~~~~~~~~~
bobek.cpp:29:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         ll v; scanf("%lld", &v);
      |               ~~~~~^~~~~~~~~~~~
bobek.cpp:33:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         ll v; scanf("%lld", &v);
      |               ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...