Submission #301296

#TimeUsernameProblemLanguageResultExecution timeMemory
301296williamMBDKAliens (IOI16_aliens)C++17
0 / 100
1 ms512 KiB
#include<bits/stdc++.h> #include "aliens.h" using namespace std; int N, M, K; vector<int> R, C; vector<vector<long long>> dp (N, vector<long long> (K)); 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()); 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...