Submission #1800693
Source Code Expand
#include<cstdio> #include<cmath> #include<algorithm> using namespace std; #define INF 1 << 29 int main(){ int n, a[100000], d[100000]; scanf("%d", &n); for(int i = 0; i < n; i++) scanf("%d", &a[i]); fill(d, d + n, INF); d[0] = 0; for(int i = 0; i < n; i++){ if(i + 1 < n) d[i + 1] = min(d[i + 1], d[i] + abs(a[i] - a[i + 1])); if(i + 2 < n) d[i + 2] = min(d[i + 2], d[i] + abs(a[i] - a[i + 2])); } printf("%d\n", d[n - 1]); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - 柱柱柱柱柱 |
User | orpheus |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 469 Byte |
Status | AC |
Exec Time | 10 ms |
Memory | 896 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:11:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &n); ^ ./Main.cpp:12:47: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] for(int i = 0; i < n; i++) scanf("%d", &a[i]); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | sample_01.txt, sample_02.txt, sample_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 0 ms | 128 KB |
sample_02.txt | AC | 0 ms | 128 KB |
sample_03.txt | AC | 1 ms | 128 KB |
subtask1_01.txt | AC | 1 ms | 128 KB |
subtask1_02.txt | AC | 0 ms | 128 KB |
subtask1_03.txt | AC | 0 ms | 128 KB |
subtask1_04.txt | AC | 10 ms | 896 KB |
subtask1_05.txt | AC | 10 ms | 896 KB |
subtask1_06.txt | AC | 10 ms | 896 KB |
subtask1_07.txt | AC | 10 ms | 896 KB |