Submission #915313

# Submission time Handle Problem Language Result Execution time Memory
915313 2024-01-23T16:33:00 Z Trisanu_Das Holiday (IOI14_holiday) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "holiday.h"
using namespace std;
#define int long long

int findMaxAttraction(int n , int start , int d , int* a){
    int ans = 0 ;
    for(int i=start;i<n;i++){
        multiset<int> el ;
        for(int j=start;j<=i;j++) el.insert(a[j])  ;
        int sum = 0;
        int rest = d-(i-start) ;
        if(rest<0) break ;
        while(el.size()>rest)
            el.erase(el.begin());
        for(int x: el) sum+=x ;
        ans=max(ans,sum);
        for(int j=start-1;j>-1;--j){
            rest = d-(min(start-j,i-start)*2+max(start-j,i-start));
            if(rest<0) break ;
            el.insert(a[j]) ;
            sum+=a[j] ;
            while(el.size()>rest){
                sum-=*el.begin();
                el.erase(el.begin()) ;
            }
            ans=max(ans,sum) ;
        }
    }
    return ans ;
}

Compilation message

holiday.cpp: In function 'long long int findMaxAttraction(long long int, long long int, long long int, long long int*)':
holiday.cpp:14:24: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   14 |         while(el.size()>rest)
      |               ~~~~~~~~~^~~~~
holiday.cpp:23:28: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   23 |             while(el.size()>rest){
      |                   ~~~~~~~~~^~~~~
/usr/bin/ld: /tmp/ccynUIO7.o: in function `main':
grader.cpp:(.text.startup+0xaf): undefined reference to `findMaxAttraction(int, int, int, int*)'
collect2: error: ld returned 1 exit status