제출 #1121529

#제출 시각아이디문제언어결과실행 시간메모리
1121529vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
50 / 100
435 ms20896 KiB
#include <bits/stdc++.h> using namespace std; #define SPEED \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL); #define pb push_back #define endl "\n" #define ALL(x) x.begin(), x.end() #define intt long long const intt mxN = 2e5 + 5; void solve() { int n, k; cin >> n >> k; vector<intt> a(n); for(int i = 0; i < n; i++) cin >> a[i]; vector<intt>l, r; for(int i = 0; i < n / 2; i++) l.pb(a[i]); for(int i = n / 2; i < n; i++) r.pb(a[i]); vector<intt> asum, bsum; for(int msk = 0; msk < (1 << l.size()); msk++) { intt sum = 0; for(int i = 0; i < 30; i++) { if(msk & (1 << i)) { sum += l[i]; } } asum.pb(sum); } for(intt msk = 0; msk < (1 << r.size()); msk++) { intt sum = 0; for(intt i = 0; i < 30; i++) { if(msk & (1 << i)) { sum += r[i]; } } bsum.pb(sum); } sort(bsum.begin(), bsum.end()); intt ans = 0; for(int i = 0; i < asum.size(); i++) { intt lft = k - asum[i]; ans += upper_bound(ALL(bsum), lft) - bsum.begin(); // cout << lft << " " << asum[i] << endl; } cout << ans << endl; } int main(){ SPEED; int tst = 1, i = 1; // cin >> tst; while(tst--) { solve(); } return 0; } /* */

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

bobek.cpp: In function 'void solve()':
bobek.cpp:48:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for(int i = 0; i < asum.size(); i++) {
      |                    ~~^~~~~~~~~~~~~
bobek.cpp: In function 'int main()':
bobek.cpp:59:18: warning: unused variable 'i' [-Wunused-variable]
   59 |     int tst = 1, i = 1;
      |                  ^
#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...