結果

問題 No.505 カードの数式2
ユーザー shinwisteria
提出日時 2017-04-21 22:46:21
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 462 bytes
コンパイル時間 3,937 ms
コンパイル使用メモリ 74,568 KB
実行使用メモリ 41,348 KB
最終ジャッジ日時 2024-07-20 05:36:25
合計ジャッジ時間 8,720 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class CardSushiki {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int ans = 0;
		for(int i = 0;i < N;i++){
			int k = s.nextInt();
			if(k == 1){
				ans += k;
			}else if(k <= 0){
				ans -= k;
			}else{
				if(ans == 0){
					ans = 1;
				}
				ans *= k;
			}
		}
		s.close();
		System.out.println(ans);

	}

}
0