Submission #261245

# Submission time Handle Problem Language Result Execution time Memory
261245 2020-08-11T15:19:12 Z Saboon Treatment Project (JOI20_treatment) C++14
0 / 100
3000 ms 3320 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
 
int T[maxn], L[maxn], R[maxn], C[maxn], p[maxn], dp[maxn];
 
int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
		cin >> T[i] >> L[i] >> R[i] >> C[i];
	for (int i = 1; i <= m; i++)
		p[i] = i;
	memset(dp, -1, sizeof dp);
	for (int _ = 0; _ < m; _++){
		for (int iit = 1; iit <= m; iit++){
			int i = p[iit];
			if (L[i] == 1)
				dp[i] = C[i];
			for (int jit = 1; jit <= m; jit++){
				int j = p[jit];
				if (abs(T[i]-T[j]) <= R[j]-L[i]+1 and dp[j] != -1)
					if (dp[i] == -1 or dp[i] > dp[j] + C[i])
						dp[i] = dp[j] + C[i];
			}
		}
	}
	int answer = -1;
	for (int i = 1; i <= m; i++)
		if (R[i] == n and dp[i] != -1 and (answer == -1 or answer > dp[i]))
			answer = dp[i];
	cout << answer << endl;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 3073 ms 3320 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1152 KB Output is correct
2 Correct 1 ms 1152 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
4 Incorrect 1 ms 1152 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1152 KB Output is correct
2 Correct 1 ms 1152 KB Output is correct
3 Correct 1 ms 1152 KB Output is correct
4 Incorrect 1 ms 1152 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3073 ms 3320 KB Time limit exceeded
2 Halted 0 ms 0 KB -