# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
912941 | 2024-01-20T04:37:32 Z | 12345678 | Discharging (NOI20_discharging) | C++17 | 111 ms | 22628 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const ll nx=1e6+5, inf=1e18; ll n, t[nx], dp[nx]; struct line { ll m, c, p; line(ll m, ll c, ll p): m(m), c(c), p(p){} }; struct convexhull { deque<line> dq; ll div(ll a, ll b) { if ((a%b)==0||(a^b)>=0) return a/b; return a/b-1; } void add(ll m, ll c) { while (dq.size()>1) { line tmp=dq.back(); dq.pop_back(); if (div(c-tmp.c, tmp.m-m)>dq.back().p) { dq.push_back(tmp); break; } } if (!dq.empty()) dq.back().p=div(c-dq.back().c, dq.back().m-m); dq.push_back(line(m, c, inf)); } ll query(ll x) { while (dq.front().p<x) dq.pop_front(); return dq.front().m*x+dq.front().c; } void show() { for (auto tmp:dq) printf("line %d %d %lld\n", tmp.m, tmp.c, tmp.p); } } c; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n; for (int i=1; i<=n; i++) cin>>t[i]; c.add(0, 0); //c.show(); for (int i=1; i<=n; i++) dp[i]=c.query(t[i])+t[i]*n, c.add(-i, dp[i]); //c.show(); cout<<dp[n]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Incorrect | 1 ms | 2396 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2392 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 2 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2396 KB | Output is correct |
11 | Correct | 1 ms | 2396 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 1 ms | 2496 KB | Output is correct |
14 | Correct | 2 ms | 2396 KB | Output is correct |
15 | Correct | 2 ms | 2396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2392 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 2 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2396 KB | Output is correct |
11 | Correct | 1 ms | 2396 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 1 ms | 2496 KB | Output is correct |
14 | Correct | 2 ms | 2396 KB | Output is correct |
15 | Correct | 2 ms | 2396 KB | Output is correct |
16 | Correct | 79 ms | 20968 KB | Output is correct |
17 | Correct | 92 ms | 21892 KB | Output is correct |
18 | Correct | 88 ms | 20264 KB | Output is correct |
19 | Correct | 91 ms | 21820 KB | Output is correct |
20 | Correct | 96 ms | 21948 KB | Output is correct |
21 | Correct | 103 ms | 21844 KB | Output is correct |
22 | Correct | 96 ms | 21316 KB | Output is correct |
23 | Correct | 88 ms | 22540 KB | Output is correct |
24 | Correct | 94 ms | 21960 KB | Output is correct |
25 | Correct | 97 ms | 22616 KB | Output is correct |
26 | Correct | 90 ms | 22628 KB | Output is correct |
27 | Correct | 99 ms | 20916 KB | Output is correct |
28 | Correct | 87 ms | 21764 KB | Output is correct |
29 | Correct | 111 ms | 21956 KB | Output is correct |
30 | Correct | 91 ms | 22344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 92 ms | 16076 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Incorrect | 1 ms | 2396 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Incorrect | 1 ms | 2396 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |