Submission #3010619
Source Code Expand
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <math.h> using namespace std; int main(){ int n; cin >> n; vector<int> a; int c; for (int i = 0; i < n; i++){ cin >> c; a.push_back(c); } int cost = 0; int t; int tmp1; int tmp2; t = a[0]; for (int i = 0; i < n - 1; i++){ tmp1 = a[i + 1]; tmp2 = a[i + 2]; if (abs(tmp1 - t) < abs(tmp2 - t)){ cost += abs(tmp1 - t); t = tmp1; } else { cost += abs(tmp2 - t); t = tmp2; i++; } } cout << cost << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - 柱柱柱柱柱 |
User | ykanebako |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 644 Byte |
Status | WA |
Exec Time | 26 ms |
Memory | 892 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 1 ms | 256 KB |
sample_02.txt | WA | 1 ms | 256 KB |
sample_03.txt | AC | 1 ms | 256 KB |
subtask1_01.txt | WA | 1 ms | 256 KB |
subtask1_02.txt | AC | 1 ms | 256 KB |
subtask1_03.txt | AC | 1 ms | 256 KB |
subtask1_04.txt | WA | 26 ms | 892 KB |
subtask1_05.txt | WA | 26 ms | 892 KB |
subtask1_06.txt | WA | 26 ms | 892 KB |
subtask1_07.txt | WA | 26 ms | 892 KB |