제출 #610914

#제출 시각아이디문제언어결과실행 시간메모리
610914skittles1412Aliens (IOI16_aliens)C++17
0 / 100
1 ms212 KiB
#include "bits/extc++.h"

using namespace std;

template <typename T>
void dbgh(const T& t) {
    cerr << t << endl;
}

template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
    cerr << t << " | ";
    dbgh(u...);
}

#ifdef DEBUG
#define dbg(...)                                              \
    cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \
    dbgh(__VA_ARGS__);
#else
#define dbg(...)
#define cerr   \
    if (false) \
    cerr
#endif

using ll = long long;

#define endl "\n"
#define long int64_t
#define sz(x) int((x).size())

long sq(long x) {
    return x * x;
}

ll take_photos(int n, int, int k, vector<int> a1, vector<int> a2) {
    vector<pair<int, int>> arr(n);
    for (int i = 0; i < n; i++) {
        arr[i] = {min(a1[i], a2[i]), max(a1[i], a2[i])};
    }
    while (true) {
        n = sz(arr);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i != j && arr[i].first <= arr[j].first &&
                    arr[j].second <= arr[i].second) {
                    arr.erase(arr.begin() + j);
                    goto loop;
                }
            }
        }
    loop:;
        if (n == sz(arr)) {
            break;
        }
    }
    sort(begin(arr), end(arr));
    n = sz(arr);
    long dp[n + 1];
    dp[n] = 0;
    for (int i = n - 1; i >= 0; i--) {
        dp[i] = 1e18;
        for (int j = i; j < n; j++) {
            dp[i] =
                min(dp[i], dp[j + 1] + sq(arr[j].second - arr[i].first + 1));
        }
    }
    return dp[0];
}
#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...