답안 #267051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
267051 2020-08-15T18:29:30 Z shayan_p 치료 계획 (JOI20_treatment) C++17
0 / 100
1 ms 768 KB
// And you curse yourself for things you never done

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int maxn = 5010;
const ll inf = 1e18 + 10;

int L[maxn], R[maxn], T[maxn], C[maxn];
ll dp[maxn];
bool mark[maxn];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie();

    int n, m;
    cin >> n >> m;
    fill(dp, dp + m, inf);
    for(int i = 0; i < m; i++){
	cin >> T[i] >> L[i] >> R[i] >> C[i];
	if(L[i] == 1)
	    dp[i] = C[i];
    }
    for(int i = 0; i < m; i++){
	int id = -1;	
	for(int j = 0; j < m; j++){
	    if(mark[j] == 0 && (id == -1 || dp[id] > dp[j]))
		id = j;
	}
	assert(id != -1);
	mark[id] = 1;
	for(int j = 0; j < m; j++){
	    if(min(R[id], R[j]) - max(L[id], L[j]) + 1 >= abs(T[id] - T[j]))
		dp[j] = min(dp[j], dp[id] + C[j]);
	}
    }
    ll ans = inf;
    for(int i = 0; i < m; i++){
	if(R[i] == n)
	    ans = min(ans, dp[i]);
    }
    if(ans == inf)
	ans = -1;
    return cout << ans << endl, 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 768 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 768 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -