제출 #1121754

#제출 시각아이디문제언어결과실행 시간메모리
1121754vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
0 / 100
280 ms22960 KiB
#include <bits/stdc++.h> using namespace std; # define int long long const int maxn = 1e6 + 5; void solve() { int n, k, cnt = 0; cin >> n >> k; vector < int > a(n); vector < int > pr1; vector < int > pr2; vector < int > p; vector < int > q; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < n / 2 + (n % 2); i++) pr1.push_back(a[i]); for(int i = n / 2 + (n % 2); i < n; i++) pr2.push_back(a[i]); for(int i = 1; i < pow(2, pr1.size()); i++) { int ans = 0; for(int j = 0; j < pr1.size(); j++) { if(i & (1 << j)) { ans += pr1[j]; } } p.push_back(ans); } for(int i = 1; i < pow(2, pr2.size()); i++) { int ans = 0; for(int j = 0; j < pr2.size(); j++) { if(i & (1 << j)) ans += pr2[j]; } q.push_back(ans); } sort(q.begin(), q.end()); for(int i = 0; i < p.size(); i++) { if(p[i] <= k) cnt++; } for(int i = 0; i < q.size(); i++) { if(q[i] <= k) cnt++; } for(int i = 0; i < p.size(); i++) { int chk = k - p[i]; int l = 0, r = q.size() - 1; if(p[i] > chk) continue; while(r >= l) { int mid = (l + r) / 2; if(q[mid] >= chk) r = mid - 1; else l = mid + 1; } cnt += (l + 1); } cout << cnt << endl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int tt = 1; // cin >> tt; while(tt--) solve(); }

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

bobek.cpp: In function 'void solve()':
bobek.cpp:24:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for(int j = 0; j < pr1.size(); j++)
      |                        ~~^~~~~~~~~~~~
bobek.cpp:37:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for(int j = 0; j < pr2.size(); j++)
      |                        ~~^~~~~~~~~~~~
bobek.cpp:45:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i = 0; i < p.size(); i++)
      |                    ~~^~~~~~~~~~
bobek.cpp:50:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i = 0; i < q.size(); i++)
      |                    ~~^~~~~~~~~~
bobek.cpp:55:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for(int i = 0; i < p.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...