답안 #1063471

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1063471 2024-08-17T19:07:40 Z Ahmed57 치료 계획 (JOI20_treatment) C++17
5 / 100
3000 ms 409556 KB
#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[5001];
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;
}

Compilation message

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()){
      |        ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 103 ms 10680 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 680 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 0 ms 600 KB Output is correct
13 Correct 0 ms 604 KB Output is correct
14 Correct 0 ms 600 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 0 ms 604 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 0 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 680 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 0 ms 600 KB Output is correct
13 Correct 0 ms 604 KB Output is correct
14 Correct 0 ms 600 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 0 ms 604 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 0 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Execution timed out 3105 ms 409556 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 103 ms 10680 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -