Submission #369511

#TimeUsernameProblemLanguageResultExecution timeMemory
369511kostia244Pinball (JOI14_pinball)C++17
0 / 100
6 ms5100 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...