답안 #310757

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
310757 2020-10-07T20:03:22 Z ly20 Building Bridges (CEOI17_building) C++17
30 / 100
3000 ms 3712 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 112345;
long long dp[MAXN];
long long sp[MAXN], h[MAXN];
int main() {
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%lld", &h[i]);
    }
    for(int i = 0; i < n; i++) {
            dp[i] = 1123456789012345678;
        int a;
        scanf("%d", &a);
        if(i == 0) sp[i] = a;
        else sp[i] = sp[i - 1] + a;
    }
    dp[0] = 0;
    for(int i = 1; i < n; i++) {
        for(int j = i - 1; j >= 0; j--) {
            dp[i] = min(dp[i], dp[j] + sp[i - 1] - sp[j] + (h[i] - h[j]) * (h[i] - h[j]));
        }
    }
    printf("%lld\n", dp[n - 1]);
    return 0;
}

Compilation message

building.cpp: In function 'int main()':
building.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
building.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |         scanf("%lld", &h[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
building.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |         scanf("%d", &a);
      |         ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3056 ms 3712 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Execution timed out 3056 ms 3712 KB Time limit exceeded
7 Halted 0 ms 0 KB -