Submission #369511

# Submission time Handle Problem Language Result Execution time Memory
369511 2021-02-21T19:13:48 Z kostia244 Pinball (JOI14_pinball) C++17
0 / 100
6 ms 5100 KB
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 505;
int n, m;
ll can[maxn][maxn], nw[maxn][maxn];
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	const ll inf = 1ll<<56;
	for(int i = 1; i <= m; i++) for(int j = 1; j <= m; j++) can[i][j] = inf;
	for(int i = 1; i <= m; i++) can[i][i] = 0;
	vector<array<int, 4>> f(n);
	for(auto &[c, l, r, d] : f) cin >> l >> r >> c >> d;
	reverse(f.begin(), f.end());
	for(auto [c, l, r, d] : f) {
		for(int i = 1; i <= m; i++) for(int j = 1; j <= m; j++) nw[i][j] = can[i][j];
		
		//cout << can[c][c] << endl;
		#define minq(a, b) a = min(a, b)
		for(int x = 1; x <= c; x++)
			for(int y = c; y <= m; y++) if(can[x][y] < inf) {
				minq(nw[min(x, l)][max(y, r)], can[x][y] + d);
			}
		for(int i = 1; i <= m; i++) for(int j = 1; j <= m; j++) {
			can[i][j] = nw[i][j];
		}
	}
	if(can[1][m] == inf) can[1][m] = -1;
	cout << can[1][m] << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 528 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 6 ms 4332 KB Output is correct
5 Runtime error 5 ms 5100 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 528 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 6 ms 4332 KB Output is correct
5 Runtime error 5 ms 5100 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 528 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 6 ms 4332 KB Output is correct
5 Runtime error 5 ms 5100 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 528 KB Output is correct
3 Correct 1 ms 1132 KB Output is correct
4 Correct 6 ms 4332 KB Output is correct
5 Runtime error 5 ms 5100 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -