Submission #1027872

#TimeUsernameProblemLanguageResultExecution timeMemory
1027872dozerHoliday (IOI14_holiday)C++14
23 / 100
12 ms1652 KiB
#include"holiday.h" #pragma GCC target("avx") #pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define sp " " #define endl "\n" #define pb push_back #define pii pair<int, int> #define st first #define nd second #define LL node * 2 #define RR node * 2 + 1 #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout) #define fastio() cin.tie(0), ios_base::sync_with_stdio(0) #define ll long long #define MAXN 200005 const int modulo = 1e9+7; const ll INF = 2e18 + 7; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { priority_queue<int> q; ll sum = 0, ans = 0; for (int i = 0; i < n; i++){ if (i > d) continue; q.push(-attraction[i]); sum += attraction[i]; while(q.size() > d - i){ int top = -q.top(); q.pop(); sum -= top; } ans = max(ans, sum); } return ans; } /* int main() { fileio(); int n, start, d; int attraction[100000]; int i, n_s; n_s = scanf("%d %d %d", &n, &start, &d); for (i = 0 ; i < n; ++i) { n_s = scanf("%d", &attraction[i]); } printf("%lld\n", findMaxAttraction(n, start, d, attraction)); cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n"; return 0; }*/

Compilation message (stderr)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:31:24: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |         while(q.size() > d - 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...