이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "holiday.h"
using namespace std;
typedef long long ll;
ll start0(int n, int d, int a[])
{
ll ans = 0;
map < ll, ll > m;
for(int i = 0; i < n; i++)
{
m[a[i]]++;
ll ost = d - i;
ll sum = 0;
for(ll val = 100; val >= 1; val--)
{
if(ost == 0)
break;
ll cur = min(ost, m[val]);
sum += cur * val;
ost -= cur;
}
ans = max(ans, sum);
}
return ans;
}
ll slow(int n, int start, int d, int a[])
{
ll ans = 0;
for(int left = 0; left <= start; left++)
{
multiset < ll > s;
ll sum = 0;
for(int i = left; i < start; i++)
{
s.insert(a[i]);
sum += a[i];
}
for(int right = start; right < n; right++)
{
s.insert(a[right]);
sum += a[right];
int left_len = start - left;
int right_len = right - start;
int ost = d - (left_len + right_len) - min(left_len, right_len);
if(ost <= 0)
break;
while(s.size() > ost)
{
auto it = s.begin();
sum -= *it;
s.erase(it);
}
ans = max(ans, sum);
}
}
return ans;
}
long long int findMaxAttraction(int n, int start, int d, int a[])
{
if(start == 0)
return start0(n, d, a);
else
return slow(n, start, d, a);
}
컴파일 시 표준 에러 (stderr) 메시지
holiday.cpp: In function 'll slow(int, int, int, int*)':
holiday.cpp:67:28: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
67 | while(s.size() > ost)
| ~~~~~~~~~^~~~~
# | 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... |