Submission #789395

#TimeUsernameProblemLanguageResultExecution timeMemory
789395NothingXDAliens (IOI16_aliens)C++17
12 / 100
104 ms8148 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef complex<ld> point; void debug_out() {cerr << endl;} template<typename Head, typename... Tail> void debug_out(Head H, Tail... T){ cerr << H << ' '; debug_out(T...); } #define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__) #define F first #define S second #define all(x) x.begin(), x.end() #define MP(x, y) make_pair(x, y) const int maxn = 1e3 + 10; const ll inf = 1e18; ll dp[maxn][maxn]; int mx[maxn]; long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) { for (int i = 0; i < n; i++){ r[i]++; c[i]++; if (r[i] > c[i]) swap(r[i], c[i]); mx[r[i]] = max(mx[r[i]], c[i]); } for (int i = 1; i <= m; i++){ if (mx[i] == 0){ for (int j = 0; j <= k; j++) dp[i][j] = dp[i-1][j]; continue; } dp[i][0] = inf; for (int j = 1; j <= k; j++){ dp[i][j] = dp[i][j-1]; int val = mx[i]; for (int k = i-1; ~k; k--){ dp[i][j] = min(dp[i][j], dp[k][j-1] + 1ll * (val-k) * (val-k)); val = max(val, mx[k]); } } } return dp[m][k]; }
#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...