Submission #97672

#TimeUsernameProblemLanguageResultExecution timeMemory
97672jasony123123Ice Hockey World Championship (CEOI15_bobek)C++11
100 / 100
235 ms20844 KiB
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> #include <array> //#include <ext/pb_ds/tree_policy.hpp> //#include <ext/pb_ds/assoc_container.hpp> using namespace std; //using namespace __gnu_pbds; #define FOR(i,start,end) for(int i=start;i<(int)(end);i++) #define FORE(i,start,end) for(int i=start;i<=(int)end;i++) #define RFOR(i,start,end) for(int i = start; i>end; i--) #define RFORE(i,start,end) for(int i = start; i>=end; i--) #define all(a) a.begin(), a.end() #define mt make_tuple #define mp make_pair #define v vector #define sf scanf #define pf printf #define dvar(x) cout << #x << " := " << x << "\n" #define darr(x,n) FOR(i,0,n) cout << #x << "[" << i << "]" << " := " << x[i] << "\n" typedef long long ll; typedef long double ld; typedef pair<int, int > pii; typedef pair<ll, ll> pll; //template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template<class T> void minn(T &a, T b) { a = min(a, b); } template<class T> void maxx(T &a, T b) { a = max(a, b); } void io() { #ifdef LOCAL_PROJECT freopen("input.in", "r", stdin); freopen("output.out", "w", stdout); #else #endif ios_base::sync_with_stdio(false); cin.tie(NULL); } const ll INF = 1e14; /***********************CEOI 2015 D2 Ice*****************************************/ int N; ll M; v<ll> A, B; v<ll> setA, setB; void gen(v<ll> &stor, v<ll> &nums, int i = 0, ll sum = 0) { if (i == nums.size()) { stor.push_back(sum); return; } gen(stor, nums, i + 1, sum); gen(stor, nums, i + 1, sum + nums[i]); } int main() { io(); cin >> N >> M; FOR(i, 0, min(20, N)) { ll x; cin >> x; A.push_back(x); } FOR(i, 0, max(0, N - 20)) { ll x; cin >> x; B.push_back(x); } gen(setA, A), gen(setB, B); sort(all(setA)), sort(all(setB)); // darr(setA, setA.size()); // darr(setB, setB.size()); ll ans = 0; for (int i = 0, j = setB.size() - 1; i < setA.size(); i++) { while (0 <= j && setB[j] + setA[i] > M) j--; ans += j + 1; } cout << ans << "\n"; }

Compilation message (stderr)

bobek.cpp: In function 'void gen(std::vector<long long int>&, std::vector<long long int>&, int, ll)':
bobek.cpp:46:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (i == nums.size()) {
      ~~^~~~~~~~~~~~~~
bobek.cpp: In function 'int main()':
bobek.cpp:70:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0, j = setB.size() - 1; i < setA.size(); i++) {
                                       ~~^~~~~~~~~~~~~
#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...