Submission #301297

#TimeUsernameProblemLanguageResultExecution timeMemory
301297williamMBDKAliens (IOI16_aliens)C++17
12 / 100
138 ms2304 KiB
#include<bits/stdc++.h> #include "aliens.h" using namespace std; int N, M, K; vector<int> R, C; vector<vector<long long>> dp; long long rec(int idx, int k){ if(idx == N) return 0; if(k == K-1) return (R[N-1] - R[idx] + 1)*(R[N-1] - R[idx] + 1); if(dp[idx][k] != -1) return dp[idx][k]; long long res = LLONG_MAX; for(int i = idx; i < N; i++){ long long c = (R[i] - R[idx] + 1) * (R[i] - R[idx] + 1); c += rec(i+1, k+1); res = min(c, res); } dp[idx][k] = res; return res; } long long take_photos(int _N, int _M, int _K, std::vector<int> _R, std::vector<int> _C) { N = _N; M = _M; K = _K; R = _R; C = _C; sort(R.begin(), R.end()); dp = vector<vector<long long>> (N, vector<long long> (K,-1)); return rec(0, 0); }
#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...