提出 #772581


ソースコード 拡げる

#define _CRT_SECURE_NO_WARNINGS  
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include<string>
#include <math.h>
#include<vector>
#include <math.h>

using namespace std;


int main() {
	int n;
	cin >> n;
	int a[100001];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long b[100001] = {0};
	b[n - 1] = 0;
	b[n - 2] = abs(a[n - 1] - a[n - 2]);
	for (int i = n - 3; i >= 0; i--) {
		int r = abs(a[i] - a[i + 1]);
		int l = abs(a[i] - a[i + 2]);
		if (r<l){
			b[i] = b[i + 1] + r;
		}
		else {
			b[i] = b[i + 2] + l;
		}
	}
	cout<< b[0] << endl;
	return 0;
}

提出情報

提出日時
問題 C - 柱柱柱柱柱
ユーザ mako
言語 C++14 (GCC 5.4.1)
得点 0
コード長 632 Byte
結果 WA
実行時間 57 ms
メモリ 1408 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 100
結果
AC × 2
WA × 1
AC × 5
WA × 5
セット名 テストケース
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 5 ms 1024 KiB
sample_02.txt WA 5 ms 1024 KiB
sample_03.txt AC 5 ms 1024 KiB
subtask1_01.txt AC 5 ms 1024 KiB
subtask1_02.txt AC 5 ms 1024 KiB
subtask1_03.txt AC 5 ms 1024 KiB
subtask1_04.txt WA 57 ms 1408 KiB
subtask1_05.txt WA 57 ms 1408 KiB
subtask1_06.txt WA 57 ms 1408 KiB
subtask1_07.txt WA 57 ms 1408 KiB