제출 #605085

#제출 시각아이디문제언어결과실행 시간메모리
605085MohamedFaresNebiliAliens (IOI16_aliens)C++14
0 / 100
2071 ms8320 KiB
#include <bits/stdc++.h> /// #pragma GCC optimize ("Ofast") /// #pragma GCC target ("avx2") /// #pragma GCC optimize("unroll-loops") using namespace std; using ll = long long; using ld = long double; #define ff first #define ss second #define pb push_back #define all(x) (x).begin(), (x).end() #define lb lower_bound const int MOD = 998244353; ll N, M, K, A[1001]; map<ll, ll> DP[500]; ll solve(ll i, ll t) { if(t < 0) return 1000000000LL * 1000000000LL; if(i == N) return 0; if(DP[i].count(t)) return DP[i][t]; ll best = 1000000000LL * 1000000000LL; for(ll l = i; l < N; l++) { ll cur = (A[l] - A[i] + 1); cur *= cur; best = min(best, cur + solve(l + 1, t - 1)); } return DP[i][t] = best; } long long take_photos(int n, int m, int k, vector<int> r, vector<int> c) { M = m, K = k; sort(r.begin(), r.end()); for(auto u : r) { if(N == 0 || A[N - 1] != u) A[N++] = u; } ll best = solve(0, k); return best; }
#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...