이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define intt long long
#define pb push_back
#define forr(i , x , y) for(int i = x; i <= y;i++)
#define fore(i , n) for(int i = 0 ; i < n;i++)
#define forn(i ,x , y) for(int i = x ; i >= y;i--)
namespace {
int read_int() {
int x;
if (scanf("%d", &x) != 1) {
fprintf(stderr, "Error while reading input\n");
exit(1);
}
return x;
}
} // namespace
const intt INF = 1e18;
vector<long long> minimum_costs(vector<int> H, vector<int> L , vector<int> R)
{
int n = (int)H.size();
int q = (int)L.size();
vector<vector<intt>> dp(n , vector<intt>(n)) ;
fore(i , n)
{
int cur = H[i];
dp[i][i] = cur;
forr(j , i+ 1, n - 1)
{
cur = max(cur , H[j]);
dp[i][j] = dp[i][j - 1] + cur;
}
cur = H[i];
forn(j , i - 1 , 0)
{
cur = max(cur , H[j]);
dp[i][j]= dp[i][j + 1] + cur;
}
}
vector<intt> res(q);
fore(i , q)
{
int l = L[i] , r = R[i];
intt ans = INF;
forr(j , l , r)
{
ans = min(ans , dp[j][l] + dp[j][r] - H[j]);
}
res[i] = ans;
}
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
meetings.cpp:10:9: warning: 'int {anonymous}::read_int()' defined but not used [-Wunused-function]
10 | int read_int() {
| ^~~~~~~~
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |