提出 #773528
ソースコード 拡げる
using System.Collections;
using System.Linq;
using System.Collections.Generic;
using System;
using System.Windows;
namespace ABC{
class ABC{
class Vector2
{
public int x;
public int y;
public int GetX(){
return x;
}
public int GetY(){
return y;
}
public Vector2(int a,int b){
x = a;
y = b;
}
}
static int[] ScanInt(){
string[] a = Console.ReadLine().Split(' ');
int[] b = new int[a.Length];
int j = 0;
foreach(string z in a){
b[j] = int.Parse(z);
j++;
}
return b;
}
static char[] ScanChar(){
string a = Console.ReadLine();
char[] b = a.ToCharArray();
return b;
}
static void Main(string[] args){
int x = int.Parse (Console.ReadLine());
int[] a = ScanInt ();
int ans = 0;
int v = 0;
while (true) {
if(v >= x-1)
break;
if(v+1 == x-1)
{
ans += Math.Abs(a[v] - a[v+1]);
v++;
break;
}
if(v+3 == x-1){
if((a[v] < a[v+1] && a[v+1] > a[v+2]) || (a[v] > a[v+1] && a[v+1] < a[v+2])){
if(Math.Abs(a[v+2]-a[v+3])+Math.Abs(a[v] - a[v+2]) > Math.Abs(a[v]-a[v+1])+Math.Abs(a[v+1] - a[v+3])){
ans += Math.Abs(a[v]-a[v+1])+Math.Abs(a[v+1] - a[v+3]);
v+=3;
}
else{
ans += Math.Abs(a[v] - a[v+2]);
v += 2;
}
}
else
{
ans += Math.Abs(a[v] - a[v+1]);
v++;
}
continue;
}
else if((a[v] < a[v+1] && a[v+1] > a[v+2]) || (a[v] > a[v+1] && a[v+1] < a[v+2])){
ans += Math.Abs(a[v] - a[v+2]);
v += 2;
}
else{
ans += Math.Abs(a[v] - a[v+1]);
v++;
}
}
Console.WriteLine (ans);
}
}
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - 柱柱柱柱柱 |
| ユーザ | udonudon |
| 言語 | C# (Mono 4.6.2.0) |
| 得点 | 0 |
| コード長 | 1791 Byte |
| 結果 | WA |
| 実行時間 | 93 ms |
| メモリ | 9304 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 | 34 ms | 2776 KiB |
| sample_02.txt | AC | 30 ms | 2648 KiB |
| sample_03.txt | AC | 31 ms | 2648 KiB |
| subtask1_01.txt | AC | 32 ms | 2648 KiB |
| subtask1_02.txt | AC | 30 ms | 2648 KiB |
| subtask1_03.txt | AC | 30 ms | 2648 KiB |
| subtask1_04.txt | WA | 90 ms | 9304 KiB |
| subtask1_05.txt | WA | 93 ms | 9304 KiB |
| subtask1_06.txt | WA | 91 ms | 9304 KiB |
| subtask1_07.txt | WA | 93 ms | 9304 KiB |