Submission #432937

#TimeUsernameProblemLanguageResultExecution timeMemory
432937yuto1115Aliens (IOI16_aliens)C++17
25 / 100
2059 ms6988 KiB
#include "aliens.h" #include <bits/stdc++.h> #define rep(i, n) for(ll i = 0; i < ll(n); i++) #define rep2(i, s, n) for(ll i = ll(s); i < ll(n); i++) #define rrep(i, n) for(ll i = ll(n)-1; i >= 0; i--) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define pb push_back #define eb emplace_back using namespace std; using ll = long long; using P = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vp = vector<P>; using vvp = vector<vp>; using vb = vector<bool>; using vvb = vector<vb>; using vs = vector<string>; template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } const int inf = 1001001001; const ll linf = 1001001001001001001; ll take_photos(int n, int m, int k, vi r, vi c) { vp v; rep(i, n) { if (r[i] <= c[i]) v.eb(r[i], c[i] + 1); else v.eb(c[i], r[i] + 1); } sort(all(v)); vi ls; int mx = 0; rep(i, n) if (chmax(mx, v[i].second)) ls.pb(i); int sz = ls.size(); vi s(sz), t(sz); rep(i, sz) { s[i] = v[ls[i]].first; t[i] = v[ls[i]].second; } vvl dp(sz + 1, vl(k + 1, linf)); dp[0][0] = 0; rep(i, sz) rep(j, k) { ll now = dp[i][j]; if (now == linf) continue; rep2(ni, i, sz) { ll wid = t[ni] - s[i]; ll lap = max(0LL, (i ? t[i - 1] : 0LL) - s[i]); ll add = wid * wid - lap * lap; chmin(dp[ni + 1][j + 1], now + add); } } ll ans = linf; rep2(i, 1, k + 1) chmin(ans, dp[sz][i]); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...