Submission #722207

#TimeUsernameProblemLanguageResultExecution timeMemory
722207Ronin13Holiday (IOI14_holiday)C++14
Compilation error
0 ms0 KiB
#include"holiday.h" #include <bits/stdc++.h> #define ll long long #define ull unsigned ll #define pb push_back #define epb emplace_back #define f first #define s second #define pii pair<int,int> #define pll pair<ll,ll> using namespace std; ll slv(int s, ll a[], int d, int x, int n){ multiset <ll> st; ll ss = 0; ll mx = 0; int cnt = 0; for(int i = s; i < n; i++){ int x = d - (cnt); cnt++; st.insert(a[i]); ss += a[i]; while(st.size() > x) ss -= *st.begin(), st.erase(st.begin()); mx = max(mx, ss); } return mx; } long long int findMaxAttraction(int n, int start, int d, int attraction[]) { ll a[n + 1]; for(int i = 0; i < n; i++) a[i] = attraction[i]; if(start == 0){ multiset <ll> st; ll s = 0; ll mx = 0; for(int i = 0; i < n; i++){ int x = d - i; st.insert(a[i]); s += a[i]; while(st.size() > x) s -= *st.begin(), st.erase(st.begin()); mx = max(mx, s); } return mx; } else{ ll ans = 0; for(int i = 0; i <= start; i++){ if(d > start - i) ll x = slv(i, a, d - (start - i), start, n); ans = max(ans, x); } for(int i = 0; i < n; i++){ if(i < n - 1- i) swap(a[i], a[n - 1 - i]); } start = n - start - 1; for(int i = 0; i <= start; i++){ if(d > start - i) ll x = slv(i, a, d - start + i, start,n); ans = max(ans, x); } return ans; } return 0; }

Compilation message (stderr)

holiday.cpp: In function 'long long int slv(int, long long int*, int, int, int)':
holiday.cpp:25:29: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |             while(st.size() > x)
      |                   ~~~~~~~~~~^~~
holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:45:29: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |             while(st.size() > x)
      |                   ~~~~~~~~~~^~~
holiday.cpp:55:16: warning: unused variable 'x' [-Wunused-variable]
   55 |             ll x = slv(i, a, d - (start - i), start, n);
      |                ^
holiday.cpp:56:28: error: 'x' was not declared in this scope
   56 |             ans = max(ans, x);
      |                            ^
holiday.cpp:65:16: warning: unused variable 'x' [-Wunused-variable]
   65 |             ll x = slv(i, a, d - start + i, start,n);
      |                ^
holiday.cpp:66:28: error: 'x' was not declared in this scope
   66 |             ans = max(ans, x);
      |                            ^