結果
問題 | No.703 ゴミ拾い Easy |
ユーザー | nono00 |
提出日時 | 2024-07-04 15:23:00 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,117 bytes |
コンパイル時間 | 3,160 ms |
コンパイル使用メモリ | 252,748 KB |
実行使用メモリ | 13,492 KB |
最終ジャッジ日時 | 2024-07-04 15:23:10 |
合計ジャッジ時間 | 9,238 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | WA | - |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 74 ms
12,672 KB |
testcase_35 | AC | 74 ms
12,664 KB |
testcase_36 | AC | 73 ms
12,544 KB |
testcase_37 | AC | 74 ms
12,544 KB |
testcase_38 | AC | 73 ms
12,544 KB |
testcase_39 | AC | 73 ms
12,672 KB |
testcase_40 | AC | 74 ms
12,672 KB |
testcase_41 | AC | 75 ms
12,672 KB |
testcase_42 | AC | 73 ms
12,600 KB |
testcase_43 | AC | 75 ms
12,672 KB |
testcase_44 | AC | 2 ms
5,376 KB |
testcase_45 | AC | 2 ms
5,376 KB |
testcase_46 | AC | 91 ms
12,668 KB |
testcase_47 | AC | 88 ms
12,672 KB |
testcase_48 | WA | - |
testcase_49 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; template <class T> using max_heap = priority_queue<T>; template <class T> using min_heap = priority_queue<T, vector<T>, greater<T>>; #define rep(i, l, r) for (ll i = (l); i < (r); i++) #define rrep(i, r, l) for (ll i = (r); i-- > (l);) #define all(x) begin(x), end(x) template <class T> bool chmin(T& lhs, T rhs) { return lhs > rhs ? (lhs = rhs, true) : false; } template <class T> bool chmax(T& lhs, T rhs) { return lhs < rhs ? (lhs = rhs, true) : false; } struct IOIO { IOIO() { cin.tie(0)->sync_with_stdio(0); } } ioio; template <class S, class T> ostream& operator<<(ostream& os, const pair<S, T>& p) { os << '(' << p.first << ", " << p.second << ')'; return os; } template <class T> ostream& operator<<(ostream& os, const vector<T>& vs) { os << '{'; rep(i, 0, (int)vs.size()) os << vs[i] << (i + 1 == (int)vs.size() ? "" : ", "); os << '}'; return os; } template <class T> ostream& operator<<(ostream& os, const set<T>& vs) { os << '{'; for (auto it = vs.begin(); it != vs.end(); it++) { if (it != vs.begin()) { os << ", "; } os << *it; } os << '}'; return os; } template <class T, class U> ostream& operator<<(ostream& os, const map<T, U>& vs) { os << '{'; for (auto it = vs.begin(); it != vs.end(); it++) { if (it != vs.begin()) { os << ", "; } os << *it; } os << '}'; return os; } #ifdef DEBUG void dump_func() { cerr << endl; } template <class Head, class... Tail> void dump_func(Head&& head, Tail&&... tail) { cerr << head; if (sizeof...(Tail) > 0) { cerr << ", "; } dump_func(std::move(tail)...); } #define dump(...) cerr << "[" + string(#__VA_ARGS__) + "] ", dump_func(__VA_ARGS__) #else #define dump(...) static_cast<int>(0) #endif int main() { int n; cin >> n; vector<ll> a(n), x(n), y(n); rep(i, 0, n) cin >> a[i]; rep(i, 0, n) cin >> x[i]; rep(i, 0, n) cin >> y[i]; using line = pair<ll, ll>; deque<line> deq; vector<ll> dp(n + 1); auto need = [](line a, line b, line c) { return (a.second - b.second) * (c.first - a.first) < (a.second - c.second) * (b.first - a.first); }; auto eval = [](line l, ll x) { return l.first * x + l.second; }; rep(i, 0, n) { line l = {-2 * x[i], dp[i] + x[i] * x[i] + y[i] * y[i]}; if (!deq.empty() && deq.back().first == l.first) { if (deq.back().second > l.second) { deq.pop_back(); deq.push_back(l); } } else { while (deq.size() >= 2) { if (need(deq[deq.size() - 2], deq[deq.size() - 1], l)) { break; } else { deq.pop_back(); } } deq.push_back(l); } while (deq.size() >= 2 && eval(deq[0], a[i]) >= eval(deq[1], a[i])) deq.pop_front(); dp[i + 1] = eval(deq.front(), a[i]) + a[i] * a[i]; } cout << dp.back() << '\n'; }