제출 #587139

#제출 시각아이디문제언어결과실행 시간메모리
587139Jomnoi휴가 (IOI14_holiday)C++17
30 / 100
70 ms1912 KiB
#include <bits/stdc++.h> #include"holiday.h" using namespace std; const int MAX_N = 1e5 + 5; int N; int A[MAX_N]; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { N = n; for(int i = 0; i < N; i++) { A[i] = attraction[i]; } long long ans = 0; if(N <= 20) { for(int mask = 0; mask < (1<<N); mask++) { int lm = -1, rm = -1, cnt = 0; long long sum = 0; for(int i = 0; i < N; i++) { if(mask & (1<<i)) { if(lm == -1) { lm = i; } rm = i; cnt++; sum += A[i]; } } if(rm - lm + min(abs(start - lm), abs(start - rm)) + cnt <= d) { ans = max(ans, sum); } } } else if(start == 0) { long long sum = 0; priority_queue <int, vector <int>, greater <int>> pq; for(int i = 0; i < min(N, d); i++) { sum += A[i]; pq.push(A[i]); while(pq.size() > d - i) { sum -= pq.top(); pq.pop(); } ans = max(ans, sum); } } else if(N <= 3000) { for(int l = start; l >= 0; l--) { long long sum = 0; priority_queue <int, vector <int>, greater <int>> pq; for(int i = start; i >= l; i--) { sum += A[i]; pq.push(A[i]); } for(int r = start + 1; r < n; r++) { sum += A[r]; pq.push(A[r]); while(!pq.empty() and pq.size() > d - (r - l) - min(start - l, r - start)) { sum -= pq.top(); pq.pop(); } ans = max(ans, sum); } } } return ans; }

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

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:43:29: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int, std::vector<int>, std::greater<int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |             while(pq.size() > d - i) {
      |                   ~~~~~~~~~~^~~~~~~
holiday.cpp:62:49: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int, std::vector<int>, std::greater<int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   62 |                 while(!pq.empty() and pq.size() > d - (r - l) - min(start - l, r - start)) {
      |                                       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...