結果

問題 No.825 賢いお買い物
ユーザー heyanxxheyanxx
提出日時 2019-07-04 15:18:55
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,099 bytes
コンパイル時間 3,476 ms
コンパイル使用メモリ 77,608 KB
実行使用メモリ 53,552 KB
最終ジャッジ日時 2023-10-19 07:36:57
合計ジャッジ時間 5,668 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
53,500 KB
testcase_01 AC 56 ms
53,536 KB
testcase_02 AC 56 ms
53,536 KB
testcase_03 AC 55 ms
53,540 KB
testcase_04 AC 56 ms
53,540 KB
testcase_05 AC 55 ms
53,504 KB
testcase_06 AC 55 ms
53,532 KB
testcase_07 AC 56 ms
53,544 KB
testcase_08 WA -
testcase_09 AC 56 ms
53,540 KB
testcase_10 AC 56 ms
52,484 KB
testcase_11 WA -
testcase_12 AC 56 ms
52,488 KB
testcase_13 AC 56 ms
53,536 KB
testcase_14 AC 57 ms
52,496 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 57 ms
53,540 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package test.demo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Yukicoder825 {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ


		try {
			String[]str2=input();

			int a=Integer.parseInt(str2[0]);
			int b=Integer.parseInt(str2[1]);
			int c=Integer.parseInt(str2[2]);
			
			if(test(a,b,c)<=0) {
				System.out.println("Impossible");
			}else {
				System.out.println(test(a,b,c));
			}

		} catch (IOException e) {
		}	

	}
	
	public static int test(int a,int b, int c) {
	  int count =a+b*10;
	  int pay=0;
	  int en=0;
	  
	  for(int i=c;i>=0;i--) {
		  if(count-((c-i)*10+i)<=0 || ((c-i))*10+i<=0) {
			  continue;
		  }
		  pay=(count-((c-i)*10+i));
		  en=i;
	  }	
	  
	  if(b-(c-en)>1) {
		  return -1;
	  }
		return pay;
	
		//(a-(c-(a/10-1+b)))%10;
		
	}
	
	public static  String[] input() throws IOException {
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		
		String str=br.readLine();
		String[]str2=str.split(" ");
		
		return str2;
	}

}
0