Submission #915310

#TimeUsernameProblemLanguageResultExecution timeMemory
915310Trisanu_DasHoliday (IOI14_holiday)C++17
0 / 100
27 ms6224 KiB
#include <bits/stdc++.h> #include "holiday.h" using namespace std; long long findMaxAttraction(int n, int s, int k, int a[]){ long long ans = 0; if(s == 0){ multiset<int> ss; long long curr; for(int j = 0; j < min(n, k - 1); j++){ ss.insert(a[j]); curr += a[j]; while(j + ss.size() > k){ curr -= *ss.begin(); ss.erase(ss.begin()); } ans = max(ans, curr); } return ans; } }

Compilation message (stderr)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:12:27: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   12 |       while(j + ss.size() > k){
      |             ~~~~~~~~~~~~~~^~~
holiday.cpp:20:1: warning: control reaches end of non-void function [-Wreturn-type]
   20 | }
      | ^
holiday.cpp:11:12: warning: 'curr' may be used uninitialized in this function [-Wmaybe-uninitialized]
   11 |       curr += a[j];
      |       ~~~~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...