Submission #950517

# Submission time Handle Problem Language Result Execution time Memory
950517 2024-03-20T11:37:05 Z hengliao Holiday (IOI14_holiday) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define pb push_back
#define vll vector<ll>
#define pll pair<ll, ll>
typedef long long ll;

ll findMaxAttraction(ll n, ll s, ll d, ll a[]){
    if(s==0){
        set<ll> st;
        ll cur=0;
        ll ans=0;
        for(ll i=0;i<n;i++){
            if(d<=0) break;
            st.insert(a[i]);
            cur+=a[i];
            while(st.size()>d){
                cur-=*st.begin();
                st.erase(st.begin());
            }
            ans=max(ans, cur);
            d--;
        }
        cout<<ans<<'\n';
    }
}

/*int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    solve();
    return 0;
}*/

Compilation message

holiday.cpp: In function 'll findMaxAttraction(ll, ll, ll, ll*)':
holiday.cpp:20:28: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   20 |             while(st.size()>d){
      |                   ~~~~~~~~~^~
holiday.cpp:29:1: warning: no return statement in function returning non-void [-Wreturn-type]
   29 | }
      | ^
/usr/bin/ld: /tmp/ccd2uneO.o: in function `main':
grader.cpp:(.text.startup+0xaf): undefined reference to `findMaxAttraction(int, int, int, int*)'
collect2: error: ld returned 1 exit status