# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
111531 | 2019-05-15T14:24:08 Z | dndhk | Building Bridges (CEOI17_building) | C++14 | 3000 ms | 3824 KB |
#include <bits/stdc++.h> #define pb push_back #define all(v) ((v).begin(), (v).end()) #define sortv(v) sort(all(v)) #define sz(v) ((int)(v).size()) #define uniqv(v) (v).erase(unique(all(v)), (v).end()) #define umax(a, b) (a)=max((a), (b)) #define umin(a, b) (a)=min((a), (b)) #define FOR(i,a,b) for(int i = (a); i <= (b); i++) #define rep(i,n) FOR(i,1,n) #define rep0(i,n) FOR(i,0,(int)(n)-1) #define FI first #define SE second #define INF 2000000000 #define INFLL 1000000000000000000LL using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAX_N = 100000; int N; vector<pll> vt; ll DP[MAX_N+1]; ll sum; int main(){ scanf("%d", &N); for(int i=0; i<N; i++){ int x; scanf("%d", &x); vt.pb({x, 0}); } for(int i=0; i<N; i++){ int y; scanf("%d", &y); vt[i].second = y; sum+=y; } DP[N-1] = -vt[N-1].second; for(int i=N-2; i>=0; i--){ DP[i] = INFLL; for(int j=i+1; j<N; j++){ DP[i] = min(DP[i], (vt[i].first-vt[j].first)*(vt[i].first-vt[j].first) + DP[j]); } DP[i] -= vt[i].second; } cout<<DP[0] + sum; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3062 ms | 3824 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Execution timed out | 3062 ms | 3824 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |