이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#define int long long
#pragma GCC optimize("Ofast")
vector<array<int,4>> rng;
int n;
map<pair<int,int>,int> dp[100001];
int solve(int l,int r,int i){
if(l>r)return 0;
if(i==rng.size()){
return 1e18;
}
if(dp[i].find(make_pair(l,r))!=dp[i].end())return dp[i][{l,r}];
int L = max(1ll,l-(rng[i][0]-rng[i-1][0])) , R = min(n,r+(rng[i][0]-rng[i-1][0]));
long long c1 = solve(L,R,i+1);
if(rng[i][2]<L||rng[i][1]>R){
}else{
long long fi = 0;
if(rng[i][1]>L){
fi+=solve(L,rng[i][1]-1,i+1);
}
if(rng[i][2]<R){
fi+=solve(rng[i][2]+1,R,i+1);
}
c1 = min(c1,fi+rng[i][3]);
}
return dp[i][{l,r}] = c1;
}
signed main(){
int m;cin>>n>>m;
rng.push_back({0,1,n,0});
for(int i = 0;i<m;i++){
int x,l,r,c;
cin>>x>>l>>r>>c;
rng.push_back({x,l,r,c});
}
sort(rng.begin(),rng.end());
long long ans = solve(1,n,1);
if(ans>=1e18)cout<<-1<<endl;
else cout<<ans<<endl;
}
컴파일 시 표준 에러 (stderr) 메시지
treatment.cpp: In function 'long long int solve(long long int, long long int, long long int)':
treatment.cpp:10:9: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 4> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
10 | if(i==rng.size()){
| ~^~~~~~~~~~~~
# | 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... |