이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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)
{
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);
while (qu.size()>d-pp)
{
sum-=qu.top();
qu.pop();
}
res=max(res,sum);
}
}
}
return res;
}
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
n=n;
s=start+1;
d=d;
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:66: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]
66 | while (qu.size()>d-pp)
| ~~~~~~~~~^~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |