이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int c=5002;
vector<long long> sz;
long long n, q, maxi[c][c], kom[c][c];
vector<long long> minimum_costs(vector<int> h, vector<int> l, vector<int> r) {
n=h.size(), q=l.size();
for (int i=0; i<n; i++) maxi[i][i]=h[i];
for (int i=0; i<n; i++) for (int j=i+1; j<n; j++) maxi[i][j]=max(maxi[i][j-1], maxi[j][j]);
for (int i=0; i<n; i++) for (int j=0; j<i; j++) maxi[i][j]=maxi[j][i];
/*for (int i=0; i<n; i++) {
for (int j=0; j<n; j++) cout << maxi[i][j] << " ";
cout << "\n";
}*/
for (int i=0; i<n; i++) for (int j=1; j<=n; j++) kom[i][j]=kom[i][j-1]+maxi[i][j-1];
for (int i=0; i<q; i++) {
long long ans=1e18;
for (int j=l[i]; j<=r[i]; j++) {
ans=min(ans, kom[j][r[i]+1]-kom[j][l[i]]);
}
sz.push_back(ans);
}
return sz;
}
# | 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... |