이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"holiday.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define bb back
#define ff first
#define ss second
using namespace std;
ll findtravel(int l, int r, int st) {
if (l >= st)
return r-st;
if (r <= st)
return st-l;
return min(abs(st-l)*2+abs(st-r), abs(st-r)*2+abs(st-l));
}
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
ll ans = 0, D = d, travel, now;
set<int> nums;
for (int i = 0; i <= start; i++) {
nums.clear(), now = 0;
for (int j = i; j < start; j++)
now += attraction[j], nums.insert(attraction[j]);
for (int j = start; j < n; j++) {
nums.insert(attraction[j]), now += attraction[j];
travel = findtravel(i, j, start);
if (D-travel <= 0) continue;
while (nums.size() > D-travel)
now -= *nums.begin(), nums.erase(*nums.begin());
ans = max(ans, now);
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:32:32: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
32 | while (nums.size() > D-travel)
| ~~~~~~~~~~~~^~~~~~~~~~
# | 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... |