結果

問題 No.825 賢いお買い物
ユーザー heyanxxheyanxx
提出日時 2019-07-04 15:39:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 1,142 bytes
コンパイル時間 4,381 ms
コンパイル使用メモリ 76,928 KB
実行使用メモリ 53,500 KB
最終ジャッジ日時 2023-10-19 07:38:15
合計ジャッジ時間 6,772 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
53,488 KB
testcase_01 AC 63 ms
53,496 KB
testcase_02 AC 57 ms
53,444 KB
testcase_03 AC 56 ms
52,460 KB
testcase_04 AC 60 ms
52,448 KB
testcase_05 AC 59 ms
53,488 KB
testcase_06 AC 58 ms
53,488 KB
testcase_07 AC 60 ms
53,500 KB
testcase_08 AC 57 ms
52,452 KB
testcase_09 AC 56 ms
52,480 KB
testcase_10 AC 58 ms
52,464 KB
testcase_11 AC 57 ms
53,480 KB
testcase_12 AC 57 ms
53,488 KB
testcase_13 AC 60 ms
53,480 KB
testcase_14 AC 58 ms
52,488 KB
testcase_15 AC 56 ms
53,492 KB
testcase_16 AC 57 ms
53,488 KB
testcase_17 AC 57 ms
52,424 KB
testcase_18 AC 56 ms
53,492 KB
testcase_19 AC 58 ms
53,480 KB
testcase_20 AC 58 ms
53,488 KB
testcase_21 AC 60 ms
52,488 KB
権限があれば一括ダウンロードができます

ソースコード

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 k=0;
	  int en=0;
	  if(c==0) {  
		  return a+b*10;
	  }else {
	  
	  for(int i=c;i>=0;i--) {
		  if(count-((c-i)*10+i)<=0 || ((c-i))*10+i<=0) {
			  continue;
		  }
		  
		  k=(count-((c-i)*10+i));
		  en=i;
	  }	
	  if((en-a)>=10) {
		  return -1;
	  }

		return k;
	
		//(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