Submission #1110881

#TimeUsernameProblemLanguageResultExecution timeMemory
1110881eyadoozIce Hockey World Championship (CEOI15_bobek)C++17
50 / 100
402 ms10852 KiB
#include <iostream> #include <algorithm> #include <vector> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <queue> #include <deque> #include <stack> #include <cmath> #include <math.h> #include <array> #include <random> #include <bitset> #include <climits> #include <cstring> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define endl '\n' #define mod 1000000007 #define INF 0x3f3f3f3f #pragma GCC optimize("O3,Ofast,unroll-loops") #pragma GCC target("avx2,sse3,sse4,avx") #pragma GCC target("popcnt") template <class x> using ordered_set = tree<x, null_type, less<x>, rb_tree_tag, tree_order_statistics_node_update>; typedef pair<int, int> ipair; int main() { cin.tie(0)->sync_with_stdio(0); long long a, b; cin >> a >> b; vector<int> p1, p2; for (int i = 0; i < a; i++) { if (i < ((a + 1) / 2)) { int x; cin >> x; p1.push_back(x); } else { int x; cin >> x; p2.push_back(x); } } vector<long long> asd; for (int i = 0; i < (1 << p2.size()); i++) { long long sum = 0; for (int j = 0; j < p2.size(); j++) { if (i & (1 << j)) { sum += p2[j]; } } asd.push_back(sum); } sort(asd.begin(), asd.end()); long long ans = 0, sum = 0; for (int i = 0; i < (1 << p1.size()); i++) { long long sum = 0; for (int j = 0; j < p1.size(); j++) { if (i & (1 << j)) sum += p1[j]; } ans += upper_bound(asd.begin(), asd.end(), (b - sum)) - asd.begin(); } cout << ans; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:70:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |         for (int j = 0; j < p2.size(); j++)
      |                         ~~^~~~~~~~~~~
bobek.cpp:87:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |         for (int j = 0; j < p1.size(); j++)
      |                         ~~^~~~~~~~~~~
bobek.cpp:83:24: warning: unused variable 'sum' [-Wunused-variable]
   83 |     long long ans = 0, sum = 0;
      |                        ^~~
#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...