Submission #267067

# Submission time Handle Problem Language Result Execution time Memory
267067 2020-08-15T18:59:01 Z shayan_p Treatment Project (JOI20_treatment) C++14
35 / 100
211 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];

bool ok(int l1, int r1, int t1, int l2, int r2, int t2){
    return r1 - l2 + 1 >= abs(t1-t2);
}

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(ok(L[id], R[id], T[id], L[j], R[j], 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;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 768 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 169 ms 512 KB Output is correct
21 Correct 165 ms 572 KB Output is correct
22 Correct 101 ms 640 KB Output is correct
23 Correct 98 ms 692 KB Output is correct
24 Correct 143 ms 692 KB Output is correct
25 Correct 107 ms 640 KB Output is correct
26 Correct 98 ms 640 KB Output is correct
27 Correct 99 ms 640 KB Output is correct
28 Correct 144 ms 696 KB Output is correct
29 Correct 108 ms 640 KB Output is correct
30 Correct 95 ms 640 KB Output is correct
31 Correct 96 ms 640 KB Output is correct
32 Correct 211 ms 640 KB Output is correct
33 Correct 150 ms 640 KB Output is correct
34 Correct 168 ms 680 KB Output is correct
35 Correct 211 ms 640 KB Output is correct
36 Correct 154 ms 760 KB Output is correct
37 Correct 164 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 768 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -