제출 #58369

#제출 시각아이디문제언어결과실행 시간메모리
58369FLDutchmanAliens (IOI16_aliens)C++14
12 / 100
131 ms2808 KiB
#include "aliens.h" #include <bits/stdc++.h> using namespace std; typedef int INT; #define pb push_back #define FOR(i, l, r) for(int i = (l); i < (r); i++) #define fst first #define snd second #define int long long typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef long long ll; const ll INF = 1e15; vi C, R; vii points; int sqr(int x) {return x*x;} long long take_photos(INT n, INT m, INT k, std::vector<INT> r, std::vector<INT> c) { FOR(i, 0, n) if(c[i] < r[i]) swap(r[i], c[i]); FOR(i, 0, n) points.pb({r[i], c[i]}); points.pb({INF, INF}); sort(points.begin(), points.end()); FOR(i, 0, n){ if(points[i].fst != points[i+1].fst){ if(C.size() == 0 || points[i].snd > C.back()) {R.pb(points[i].fst); C.pb(points[i].snd);} } } //FOR(i, 0, C.size()){ // cout << R[i] << " " << C[i] << endl; //} vector<vi> dp; int N = C.size(); dp.assign(N+1, vi(k+1, -1)); FOR(i, 0, N) dp[i][0] = INF; FOR(K, 0, k+1) dp[N][K] = 0; FOR(K, 1, k+1){ for(int i = N-1; i >= 0; i--){ int mi = INF; FOR(j, i+1, N+1) mi = min(mi, dp[j][K-1] + sqr(C[j-1]+1 - R[i])); dp[i][K] = mi; } } //FOR(K, 0, k+1) { // FOR(i, 0, N+1) cout << dp[i][K] << " "; // cout<<endl; //} return dp[0][k]; } /* 5 7 2 0 3 4 4 4 6 4 5 4 6 */
#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...