Submission #915310

# Submission time Handle Problem Language Result Execution time Memory
915310 2024-01-23T16:26:38 Z Trisanu_Das Holiday (IOI14_holiday) C++17
0 / 100
27 ms 6224 KB
#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

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 time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 5468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 6224 KB Output isn't correct
2 Halted 0 ms 0 KB -