Submission #129514

#TimeUsernameProblemLanguageResultExecution timeMemory
129514antimirageHoliday (IOI14_holiday)C++14
Compilation error
0 ms0 KiB
#include "holiday.h" #include "grader.cpp" #include <bits/stdc++.h> using namespace std; multiset <int> st; inline long long max (long long a, long long b) { return a < b ? b : a; } long long int findMaxAttraction(int n, int start, int d, int a[]) { long long ans = 0, sum = 0; if (start == 0) { for (int i = 0; i < n; i++) { if (i >= d) break; st.insert(a[i]); sum += a[i]; int k = d - i; while (st.size() > k) { sum -= *st.begin(); st.erase(st.begin()); } ans = max(ans, sum); } } else { for (int x = 0; x <= d; x++) { long long res1 = 0, res2 = 0; st.clear(); sum = 0; int rem = d - x; for (int i = 0; i < x; i++) { if (start + i >= n) break; st.insert( a[start + i] ); sum += a[start + i]; int k = x - i; while (st.size() > k) { sum -= *st.begin(); st.erase(st.begin()); } res1 = max(res1, sum); } st.clear(); sum = 0; for (int i = 1; i * 2 <= rem; i++) { if (start - i < 0) break; st.insert( a[start - i] ); sum += a[start - i]; int k = rem - i * 2; while (st.size() > k) { sum -= *st.begin(); st.erase(st.begin()); } res2 = max(res2, sum); } ans = max(ans, res1 + res2); res1 = 0, res2 = 0; st.clear(); sum = 0; for (int i = 0; i * 2 <= x; i++) { if (start + i >= n) break; st.insert( a[start + i] ); sum += a[start + i]; int k = x - i * 2; while (st.size() > k) { sum -= *st.begin(); st.erase(st.begin()); } res1 = max(res1, sum); } st.clear(); sum = 0; for (int i = 1; i < rem; i++) { if (start - i < 0) break; st.insert( a[start - i] ); sum += a[start - i]; int k = rem - i; while (st.size() > k) { sum -= *st.begin(); st.erase(st.begin()); } res2 = max(res2, sum); } ans = max(ans, res1 + res2); } } return ans; } /** 5 2 7 10 2 20 30 1 **/

Compilation message (stderr)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:23:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while (st.size() > k) {
           ~~~~~~~~~~^~~
holiday.cpp:46:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (st.size() > k) {
            ~~~~~~~~~~^~~
holiday.cpp:61:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (st.size() > k) {
            ~~~~~~~~~~^~~
holiday.cpp:81:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (st.size() > k) {
            ~~~~~~~~~~^~~
holiday.cpp:97:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (st.size() > k) {
            ~~~~~~~~~~^~~
/tmp/ccqpJgp9.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccnmZ5Jw.o:holiday.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status