# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
397418 | 2021-05-02T06:40:57 Z | Nicholas_Patrick | Building Bridges (CEOI17_building) | C++17 | 3000 ms | 4392 KB |
#include <cstdio> #include <queue> using namespace std; struct line{ long long m, c; line(long long m, long long c):m(m), c(c){} long long eval(long long x){ return m*x+c; } }; int main(){ int n; scanf("%d", &n); vector<int> h(n), w(n); for(int& i: h) scanf("%d", &i); long long sumw=0; for(int& i: w){ scanf("%d", &i); sumw+=i; i=-i; } vector<line> ch; ch.emplace_back(-2*h[0], (long long)h[0]*h[0]+w[0]); for(int i=1; i+1<n; i++){ long long cost=1e18; for(auto& j: ch) cost=min(cost, j.eval(h[i])); cost+=(long long)h[i]*h[i]+w[i]; ch.emplace_back(-2*h[i], (long long)h[i]*h[i]+cost); } long long ans=1e18; for(auto& j: ch) ans=min(ans, j.eval(h[n-1])); ans+=(long long)h[n-1]*h[n-1]+w[n-1]+sumw; printf("%lld\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 284 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 2 ms | 332 KB | Output is correct |
5 | Correct | 2 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3058 ms | 4392 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 284 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 2 ms | 332 KB | Output is correct |
5 | Correct | 2 ms | 332 KB | Output is correct |
6 | Execution timed out | 3058 ms | 4392 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |