제출 #962938

#제출 시각아이디문제언어결과실행 시간메모리
962938penguin133Aliens (IOI16_aliens)C++17
12 / 100
92 ms5608 KiB
#include <bits/stdc++.h> using namespace std; #include "aliens.h" //#define int long long typedef long long ll; #define pi pair<int, int> #define pii pair<int, pi> #define fi first #define se second #ifdef _WIN32 #define getchar_unlocked _getchar_nolock #endif mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll dp[505][505], mn[1000005]; pi stuf[1000005]; long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> c) { for(int i = 0; i <= m; i++)mn[i] = 1e18; for(int i = 0; i < n; i++){ if(r[i] > c[i])swap(r[i], c[i]); mn[c[i]] = min(mn[c[i]], (ll)r[i]); stuf[i] = {c[i], r[i]}; } sort(stuf, stuf + n); for(int i = m - 1; i >= 0; i--)mn[i] = min(mn[i], mn[i + 1]); //return 0; for(int i = 0; i <= n; i++)dp[i][0] = 1e18; for(int i = 0; i < n; i++){ for(int j = 1; j <= k; j++){ dp[i][j] = 1e18; for(int a = i; a >= 0; a--){ if(j)dp[i][j] = min(dp[i][j], (a ? dp[a - 1][j - 1] : 0) + (stuf[i].fi - mn[stuf[a].fi] + 1) * (stuf[i].fi - mn[stuf[a].fi] + 1) ); } } } return dp[n - 1][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...