Submission #964144

#TimeUsernameProblemLanguageResultExecution timeMemory
964144hariaakas646Aliens (IOI16_aliens)C++14
4 / 100
1 ms600 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; #define scd(t) scanf("%d", &t) #define sclld(t) scanf("%lld", &t) #define forr(i, j, k) for (int i = j; i < k; i++) #define frange(i, j) forr(i, 0, j) #define all(cont) cont.begin(), cont.end() #define mp make_pair #define pb push_back #define f first #define s second typedef long long int lli; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<lli> vll; typedef vector<string> vs; typedef vector<pii> vii; typedef vector<vi> vvi; typedef map<int, int> mpii; typedef set<int> seti; typedef multiset<int> mseti; typedef long double ld; long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) { vi val(m); frange(i, n) { int id = max(r[i], c[i]); val[id] = max(val[id], id-min(r[i], c[i])+1); } vector<vll> dp(m, vll(k+1, 1e17)); if(val[0]) { forr(i, 1, k+1) dp[0][i] = 1; } else { frange(i, k+1) dp[0][i] = 0; } forr(i, 1, m) { forr(j, 1, k+1) { dp[i][j] = dp[i][j-1]; lli c = (lli)val[i]; for(lli l=1; i-l>=0; l++) { if(val[i-l] && val[i-l]+l>c) { dp[i][j] = min(dp[i][j], 2*c*min(l, c) - min(l, c) * min(l, c) + dp[i-l][j-1]); c = val[i-l] + l; } else dp[i][j] = min(dp[i][j], dp[i-l][j-1] + c*c); // dp[i][j] = max(dp[i][j], ) } dp[i][j] = min(dp[i][j], c*c); } } return dp[m-1][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...