제출 #469047

#제출 시각아이디문제언어결과실행 시간메모리
469047flashmtAliens (IOI16_aliens)C++17
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> using namespace std; const long long oo = 1LL << 60; long long take_photos(int n, int m, int k, vector<int> r, vector<int> c) { vector<int> id(n); for (int i = 0; i < n; i++) { if (r[i] > c[i]) swap(r[i], c[i]); id[i] = i; } sort(begin(id), end(id), [&](int u, int v) { return r[u] + c[u] < r[v] + c[v]; }); vector<vector<long long>> f(n + 1, vector<long long>(n + 1, oo)); f[0][0] = 0; for (int i = 1; i <= k; i++) for (int j = 1; j <= n; j++) { f[i][j] = oo; int minX = n, maxY = -1; for (int jj = j - 1; jj >= 0; jj--) { minX = min(minX, r[id[jj]]); maxY = max(maxY, c[id[jj]]); int area = (maxY - minX + 1LL) * (maxY - minX + 1); f[i][j] = min(f[i][j], f[i - 1][jj] + area); } } long long ans = oo; for (int i = 1; i <= k; i++) ans = min(ans, f[i][n]); 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...