Submission #369513

#TimeUsernameProblemLanguageResultExecution timeMemory
369513kostia244Pinball (JOI14_pinball)C++17
0 / 100
1 ms492 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); vector<int> comp; for(auto &[c, l, r, d] : f) cin >> l >> r >> c >> d, comp.push_back(l), comp.push_back(r); sort(comp.begin(), comp.end()); comp.erase(unique(comp.begin(), comp.end()), comp.end()); for(auto &[c, l, r, d] : f) l = lower_bound(comp.begin(), comp.end(), l) - comp.begin()+1; for(auto &[c, l, r, d] : f) r = lower_bound(comp.begin(), comp.end(), r) - comp.begin()+1; m = comp.size(); 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 << l << " " << r << endl; //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...