제출 #1054084

#제출 시각아이디문제언어결과실행 시간메모리
1054084otariusIce Hockey World Championship (CEOI15_bobek)C++17
40 / 100
114 ms9964 KiB
#include <bits/stdc++.h> #include <bits/extc++.h> using namespace __gnu_pbds; using namespace std; // #pragma GCC optimize("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define ff first #define sc second #define pb push_back #define ll long long #define pll pair<ll, ll> #define pii pair<int, int> #define ull unsigned long long #define all(x) (x).begin(),(x).end() #define int long long // #define int unsigned long long // #define ordered_set(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> // #define ordered_multiset(T) tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update> void open_file(string filename) { freopen((filename + ".in").c_str(), "r", stdin); freopen((filename + ".out").c_str(), "w", stdout); } // const ll mod = 1e9 + 7; // const ll mod = 998244353; const ll inf = 1e9; const ll biginf = 1e18; // const int maxN; void solve() { int n; ll m; cin >> n >> m; vector<int> a, b; vector<ll> arr1, arr2; for (int i = 1; i <= n; i++) { int x; cin >> x; if (x <= (n + 1) / 2) a.pb(x); else b.pb(x); } int x = a.size(); for (int i = 0; i < (1 << x); i++) { ll sum = 0; for (int j = 0; j < x; j++) if ((i >> j) & 1) sum += a[j]; if (sum <= m) arr1.pb(sum); } x = b.size(); for (int i = 0; i < (1 << x); i++) { ll sum = 0; for (int j = 0; j < x; j++) if ((i >> j) & 1) sum += b[j]; if (sum <= m) arr2.pb(sum); } ll ans = 0; sort(all(arr1)); sort(all(arr2)); for (ll x : arr1) { ans += lower_bound(all(arr2), m - x + 1) - arr2.begin(); } cout << ans; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t = 1; // cin >> t; while (t--) { solve(); cout << '\n'; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

bobek.cpp: In function 'void open_file(std::string)':
bobek.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((filename + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bobek.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen((filename + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...