제출 #749940

#제출 시각아이디문제언어결과실행 시간메모리
749940Abrar_Al_Samit휴가 (IOI14_holiday)C++17
23 / 100
5048 ms5324 KiB
#include <bits/stdc++.h>
#include"holiday.h"
using namespace std;

int get(int i, int j, int x) {
    return j-i + min(x-i, j-x);
}
long long int findMaxAttraction(int n, int start, int d, int a[]) {
    long long ans = 0;
    for(int i=0; i<=start; ++i) {
        if(start-i>d) continue;

        multiset<int>list;
        long long cur = 0;
        for(int j=i; j<start; ++j) {
            list.insert(a[j]);

            cur += a[j];
        }
        while(list.size()+start-i>d) {
            cur -= *list.begin();
            list.erase(list.begin());
        }

        for(int j=start; j<n && get(i, j, start)<=d; ++j) {
            int travel_cost = get(i, j, start);
            if(travel_cost+list.size()>d) {
                cur -= *list.begin();
                list.erase(list.begin());
            }   
            if(travel_cost+list.size()>d) {
                cur -= *list.begin();
                list.erase(list.begin());
            }   

            if(travel_cost+list.size()<d) {
                list.insert(a[j]);
                cur += a[j];
            } else {
                if(a[j]>*list.begin()) {
                    cur -= *list.begin();
                    list.erase(list.begin());
                    cur += a[j];
                    list.insert(a[j]);
                }
            }

            ans = max(ans, cur);
        }
    }
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:20:34: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |         while(list.size()+start-i>d) {
      |               ~~~~~~~~~~~~~~~~~~~^~
holiday.cpp:27:39: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |             if(travel_cost+list.size()>d) {
      |                ~~~~~~~~~~~~~~~~~~~~~~~^~
holiday.cpp:31:39: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |             if(travel_cost+list.size()>d) {
      |                ~~~~~~~~~~~~~~~~~~~~~~~^~
holiday.cpp:36:39: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |             if(travel_cost+list.size()<d) {
      |                ~~~~~~~~~~~~~~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...