제출 #432019

#제출 시각아이디문제언어결과실행 시간메모리
432019TangentAliens (IOI16_aliens)C++17
4 / 100
1 ms204 KiB
#include "aliens.h" #include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vii; typedef vector<ll> vll; typedef vector<pii> vpii; typedef vector<pll> vpll; typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<vpii> vvpii; typedef vector<vpll> vvpll; #define ffor(i, a, b) for (ll i = (a); i < (ll)(b); i++) #define fford(i, a, b) for (ll i = (a); i > (ll)(b); i--) #define rep(i, n) ffor(i, 0, n) #define forin(x, a) for (auto &x: a) #define all(a) a.begin(), a.end() #define sq(x) (x) * (x) long long take_photos(int n, int m, int k, std::vector<int> r, std::vector<int> cc) { vpii intervals; rep(i, n) { if (r[i] > cc[i]) { swap(r[i], cc[i]); } intervals.emplace_back(r[i], -cc[i]); } sort(all(intervals)); vpii merged = {{intervals[0].first, -intervals[0].second}}; ffor(i, 1, intervals.size()) { if (-intervals[i].second > merged.back().second) { merged.emplace_back(intervals[i].first, -intervals[i].second); } } while ((int)merged.size() > k) { int besti = 0; ll mincost = 1ll << 62; rep(i, merged.size() - 1) { int a, b, c, d; tie(a, b) = merged[i]; tie(c, d) = merged[i + 1]; ll cost = sq(d - a + 1) - sq(b - a + 1) - sq(d - c + 1) + sq(max(0, b - c + 1)); if (cost < mincost) { mincost = cost; besti = i; } } merged[besti].second = merged[besti + 1].second; merged.erase(merged.begin() + besti + 1); } ll res = sq(merged[0].second - merged[0].first + 1); rep(i, merged.size() - 1) { int a, b, c, d; tie(a, b) = merged[i]; tie(c, d) = merged[i + 1]; res += sq(d - c + 1) - sq(max(0, b - c + 1)); } return res; }
#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...