提出 #1247514
ソースコード 拡げる
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
// 整数の入力
int n = sc.nextInt();
int a[] = new int[n];
for(int i = 0;i<a.length;i++)
{
a[i] = sc.nextInt();
}
int b[] = new int[n];
b[0] = a[0];
int count = 0;
for(int i = 0;i<a.length-1;i++)
{
b[i+1] = b[i] + a[i+1];
if(b[i+1]*b[i]>0)
{
count += Math.abs(b[i+1])+1;
if(b[i+1]>0) b[i+1]=-1;
else b[i+1] = 1;
}
else if(b[i+1] == 0)
{
if(b[i]>0) b[i+1]=-1;
else b[i+1] = 1;
count++;
}
}
System.out.println(count);
}
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | A - Three-letter acronym |
| ユーザ | pythagorea1 |
| 言語 | Java7 (OpenJDK 1.7.0) |
| 得点 | 0 |
| コード長 | 731 Byte |
| 結果 | RE |
| 実行時間 | 96 ms |
| メモリ | 20820 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 100 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00-00.txt, 00-01.txt, 00-02.txt, 00-03.txt |
| All | 00-00.txt, 00-01.txt, 00-02.txt, 00-03.txt, 01-00.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00-00.txt | RE | 95 ms | 20564 KiB |
| 00-01.txt | RE | 95 ms | 18900 KiB |
| 00-02.txt | RE | 95 ms | 18900 KiB |
| 00-03.txt | RE | 95 ms | 18772 KiB |
| 01-00.txt | RE | 96 ms | 16980 KiB |
| 01-01.txt | RE | 94 ms | 18772 KiB |
| 01-02.txt | RE | 95 ms | 18900 KiB |
| 01-03.txt | RE | 95 ms | 20820 KiB |
| 01-04.txt | RE | 94 ms | 18772 KiB |
| 01-05.txt | RE | 93 ms | 18772 KiB |
| 01-06.txt | RE | 96 ms | 19028 KiB |