Submission #889745

#TimeUsernameProblemLanguageResultExecution timeMemory
889745UmairAhmadMirzaAliens (IOI16_aliens)C++17
0 / 100
0 ms348 KiB
#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 = 0; 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 <=min(i,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)

aliens.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...