# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
889743 | UmairAhmadMirza | Aliens (IOI16_aliens) | C++14 | 1 ms | 600 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma once
#include <bits/stdc++.h>
using namespace std;
int const N=505;
long long const inf=1e9;
long long dp[N][N];
long long take_photos(int n, int m, int k, vector<int> r, vector<int> c){
for (int i = 1; i <=n; ++i)
for(int j = 0; j <=k; ++j)
dp[i][j]=inf;
vector<long long> v;
v.push_back(r[0]);
for (int i = 1; i < n; ++i)
if(r[i]!=r[i-1])
v.push_back(r[i]);
n=v.size();
dp[0][0]=0;
k=min(n,k);
for (int i = 1; i <=n; ++i){
for(int j = 1; j <=k; ++j){
dp[i][j]=dp[i][j-1];
for (int ii = 0; ii < i; ++ii){
long long sm=(abs(v[i-1]-v[ii])+1);
sm*=sm;
dp[i][j]=min(dp[i][j],dp[ii][j-1]+sm);
}
}
}
return dp[n][k];
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |