Submission #10405807
Source Code Expand
//https://atcoder.jp/contests/dp/tasks/dp_a //29-02-2020 #include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); #ifndef ONLINE_JUDGE freopen ("input.txt", "r", stdin); freopen ("output.txt", "w", stdout); #endif int n; cin >> n; vector <int> h(n), dp(n, 0); for (int i = 0; i < n; ++i) { cin >> h[i]; } dp[0] = 0; dp[1] = abs (h[1] - h[0]); for (int i = 2; i < n; ++i) { dp[i] = min (dp[i - 1] + abs (h[i] - h[i - 1]), dp[i - 2] + abs (h[i] - h[i - 2])); } cout << dp[n - 1] << '\n'; }
Submission Info
Submission Time | |
---|---|
Task | A - Frog 1 |
User | chilledMINT |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 595 Byte |
Status | RE |
Exec Time | 101 ms |
Memory | 384 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:10:36: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result] freopen ("input.txt", "r", stdin); ^ ./Main.cpp:11:38: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result] freopen ("output.txt", "w", stdout); ^
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 0 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 0_00, 0_01, 0_02, 1_00, 1_01, 1_02, 1_03, 1_04, 1_05, 1_06, 1_07 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00 | RE | 101 ms | 384 KB |
0_01 | RE | 99 ms | 256 KB |
0_02 | RE | 99 ms | 256 KB |
1_00 | RE | 98 ms | 256 KB |
1_01 | RE | 98 ms | 256 KB |
1_02 | RE | 98 ms | 256 KB |
1_03 | RE | 98 ms | 256 KB |
1_04 | RE | 100 ms | 256 KB |
1_05 | RE | 99 ms | 256 KB |
1_06 | RE | 99 ms | 256 KB |
1_07 | RE | 97 ms | 256 KB |