提出 #772056
ソースコード 拡げる
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX_N 100000
int n;
int a[MAX_N];
int distabs(int b1, int b2){
return abs(a[b1] - a[b2]);
}
int main(){
cin >> n;
for (int i = 0; i < n; i++){
cin >> a[i];
}
int sum=0;
for (int i = 0; i < n; i++){
if (i < n - 3){
if (abs(a[i] - a[i + 1]) + abs(a[i + 1] - a[i + 3])
>abs(a[i] - a[i + 2]) + abs(a[i + 2] - a[i + 3])){
sum += abs(a[i] - a[i + 2]) + abs(a[i + 2] - a[i + 3]);
}
else{
sum += abs(a[i] - a[i + 1]) + abs(a[i + 1] - a[i + 3]);
}
i += 2;
}else if (i < n - 2){
if (abs(a[i] - a[i + 1])>abs(a[i] - a[i + 2])){
sum += abs(a[i] - a[i + 2]);
i++;
}
else{
sum += abs(a[i] - a[i + 1]);
}
}
}
cout << sum << endl;
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - 柱柱柱柱柱 |
| ユーザ | gotchman01 |
| 言語 | C++14 (GCC 5.4.1) |
| 得点 | 0 |
| コード長 | 850 Byte |
| 結果 | WA |
| 実行時間 | 57 ms |
| メモリ | 640 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 100 | ||||||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| 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 |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| sample_01.txt | AC | 4 ms | 256 KiB |
| sample_02.txt | AC | 4 ms | 256 KiB |
| sample_03.txt | WA | 4 ms | 256 KiB |
| subtask1_01.txt | WA | 4 ms | 256 KiB |
| subtask1_02.txt | WA | 4 ms | 256 KiB |
| subtask1_03.txt | WA | 4 ms | 256 KiB |
| subtask1_04.txt | WA | 57 ms | 640 KiB |
| subtask1_05.txt | WA | 56 ms | 640 KiB |
| subtask1_06.txt | WA | 57 ms | 640 KiB |
| subtask1_07.txt | WA | 55 ms | 640 KiB |