제출 #853063

#제출 시각아이디문제언어결과실행 시간메모리
853063onepunchac168휴가 (IOI14_holiday)C++14
47 / 100
5094 ms4032 KiB
#include"holiday.h"
#include <bits/stdc++.h>
using namespace std;

#define task "STOUR"
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair <ll,ll> ii;

const char nl='\n';
/*
void onepunchac168();

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    if (fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    onepunchac168();
}*/
ll n,s,d;
const int N=1e5+5;
ll a[N];
ll sub1()
{
    priority_queue<ll,vector <ll> ,greater <ll> > qu;
    ll res=0;
    ll sum=0;
    for (int i=1;i<=n;i++)
    {
        qu.push(a[i]);
        sum+=a[i];
        while (qu.size()>d-i+1)
        {
            if (qu.empty())
            {
                break;
            }
            sum-=qu.top();
            qu.pop();
        }
        res=max(res,sum);
    }
    return res;

}
const int M=3e3+5;

ll sub2()
{
    ll res=0;
    for (int i=1;i<=s;i++)
    {
        priority_queue<ll,vector <ll> ,greater <ll> > qu;
        ll sum=0;
        for (int j=i;j<=n;j++)
        {
            qu.push(a[j]);
            sum+=a[j];
            if (j>=s)
            {
                ll pp=(s-i)+(j-s)+min(s-i,j-s);
                if (pp>d)
                {
                    break;
                }
                while (qu.size()>d-pp)
                {
                    if (qu.empty())
                    {
                        break;
                    }
                    sum-=qu.top();
                    qu.pop();
                }
                res=max(res,sum);
            }
        }
    }
    return res;
}

long long int findMaxAttraction(int na, int start, int da, int attraction[]) {
    n=na;
    s=start+1;
    d=da;
    for (int i=0;i<n;i++)
    {
        a[i+1]=attraction[i];
    }
    if (s==1)
    {
        return sub1();
    }
    return sub2();
}
/*
void onepunchac168()
{
    cin>>n>>s>>d;
    s++;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    if (s==1)
    {
        sub1();
    }
    else sub2();


}
*/

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

holiday.cpp: In function 'll sub1()':
holiday.cpp:40:25: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   40 |         while (qu.size()>d-i+1)
      |                ~~~~~~~~~^~~~~~
holiday.cpp: In function 'll sub2()':
holiday.cpp:74:33: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   74 |                 while (qu.size()>d-pp)
      |                        ~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...