답안 #46512

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
46512 2018-04-21T08:50:49 Z 1Khan Building Bridges (CEOI17_building) C++14
30 / 100
3000 ms 1692 KB
#include <bits/stdc++.h>

using namespace std;

#define Tupizm ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define ONE exit(0);
#define nl "\n"

#define fly return

#define all(x) x.begin(0), x.end(0);
#define sz(x) (int)x.size();

#define pb push_back
#define ppb pop_back

typedef long long ll;
typedef double db;

const int N = 1e5 + 5;
const int M = 1e9 + 7;

int n, a[N], b[N];
int dp[N];
int sum(int l, int r){
    int q = 0;
    for(int i = l + 1; i < r; ++i){
        q += b[i];
    }
    fly q;
}
int hello(){
    for(int i = 2; i <= n; ++i){
        dp[i] = M;
    }
}
int pff(int l, int r){
    return (a[l] - a[r]) * (a[l] - a[r]);
}
int main(){
    
    Tupizm
    
    cin >> n;
    hello();
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
    }
    for(int i = 1; i <= n; ++i){
        cin >> b[i];
    }
    for(int i = 2; i <= n; ++i){
        for(int j = i - 1; j >= 1; --j){
            dp[i] = min(dp[i], dp[j] + sum(j, i) + (pff(i, j)));
        }
    }
    cout << dp[n] << nl;
    ONE
}

Compilation message

building.cpp: In function 'int hello()':
building.cpp:37:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 106 ms 560 KB Output is correct
5 Correct 107 ms 560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3053 ms 1692 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 106 ms 560 KB Output is correct
5 Correct 107 ms 560 KB Output is correct
6 Execution timed out 3053 ms 1692 KB Time limit exceeded
7 Halted 0 ms 0 KB -