Submission #435845

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
4358452021-06-23 19:26:55HegdahlAliens (IOI16_aliens)C++17
25 / 100
2067 ms6988 KiB
#include <bits/stdc++.h>
#include "aliens.h"
#define ar array
using namespace std;
using ll = long long;
int n, m, k;
vector<ar<ll, 2>> a;
const ll INF = 1LL<<60;
ll sq(ll a) { return a*a; }
void minset(ll &p, ll v) { if (v < p) p = v; }
ll solve() {
vector<vector<ll>> dp(n+1, vector<ll>(k+1, INF));
dp[0][0] = 0;
for (int kk = 0; kk < k; ++kk) {
for (int i = 0; i < n; ++i) {
int pr = i==0 ? -1 : a[i-1][1];
int l = a[i][0], r = a[i][1];
for (int j = i+1; j <= n; ++j) {
r = a[j-1][1];
minset(dp[j][kk+1], dp[i][kk] + sq(r-l+1) - sq(max(0, pr-l+1)));
}
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...