Submission #786211

#TimeUsernameProblemLanguageResultExecution timeMemory
786211Magikarp4000Aliens (IOI16_aliens)C++17
12 / 100
87 ms2316 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; #define OPTM ios_base::sync_with_stdio(0); cin.tie(0); #define INF int(1e9+7) #define ln '\n' #define ll long long #define ull unsigned long long #define ui unsigned int #define us unsigned short #define FOR(i,s,n) for (int i = s; i < n; i++) #define FORR(i,n,s) for (int i = n; i > s; i--) #define FORX(u, arr) for (auto u : arr) #define PB push_back #define in(v,x) (v.find(x) != v.end()) #define F first #define S second #define PII pair<int, int> #define PLL pair<ll, ll> #define UM unordered_map #define US unordered_set #define PQ priority_queue #define ALL(v) v.begin(), v.end() const ll LLINF = 1e18+1; #define int long long const int MAXN = 5e2+5; int n; int dp[MAXN][MAXN]; vector<PII> v; int sq(int x) {return x*x;} long long take_photos(int32_t N, int32_t m, int32_t k, vector<int32_t> R, vector<int32_t> C) { US<int> vis; FOR(i,0,N) { if (!vis.count(R[i])) { vis.insert(R[i]); v.PB({R[i],C[i]}); } } sort(ALL(v)); n = v.size(); FOR(j,0,k+1) dp[0][j] = 0LL; FOR(i,1,n+1) FOR(j,0,k+1) dp[i][j] = LLINF; FOR(i,1,n+1) { FOR(j,1,k+1) { FOR(l,0,i) { dp[i][j] = min(dp[i][j], dp[l][j-1]+sq(v[i-1].F-v[l].F+1LL)); } } } return dp[n][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...