結果

問題 No.1015 おつりは要らないです
ユーザー cnt_focnt_fo
提出日時 2020-04-03 23:23:22
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 3,596 bytes
コンパイル時間 3,082 ms
コンパイル使用メモリ 78,288 KB
実行使用メモリ 57,764 KB
最終ジャッジ日時 2023-09-16 04:55:58
合計ジャッジ時間 9,346 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,524 KB
testcase_01 AC 45 ms
49,452 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 44 ms
49,528 KB
testcase_07 AC 45 ms
49,496 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 201 ms
55,956 KB
testcase_16 AC 218 ms
56,480 KB
testcase_17 AC 214 ms
56,540 KB
testcase_18 AC 212 ms
55,852 KB
testcase_19 AC 205 ms
56,144 KB
testcase_20 AC 224 ms
56,160 KB
testcase_21 AC 225 ms
56,040 KB
testcase_22 AC 203 ms
56,012 KB
testcase_23 AC 190 ms
55,624 KB
testcase_24 AC 213 ms
56,036 KB
testcase_25 AC 198 ms
55,732 KB
testcase_26 AC 190 ms
55,548 KB
testcase_27 AC 201 ms
55,760 KB
testcase_28 AC 187 ms
55,992 KB
testcase_29 AC 201 ms
55,596 KB
testcase_30 AC 44 ms
49,532 KB
testcase_31 AC 166 ms
56,240 KB
testcase_32 AC 159 ms
56,160 KB
testcase_33 AC 217 ms
57,764 KB
testcase_34 WA -
testcase_35 AC 45 ms
49,828 KB
testcase_36 AC 44 ms
49,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
 
public class Main {
 
	void submit() {
	    int N = nextInt();
	    int X = nextInt();
	    int Y = nextInt();
	    int Z = nextInt();	    

	    int[] A = new int[N];

	    for(int i=0; i<N; i++){
	        A[i] = nextInt();
	    }
	    
	    String buy = "Yes";
        
        for(int i=0; i<N; i++){
            if(A[i]<1000){
                if(X>0){
                    X--;
                }else if(Y>0){
                    Y--;
                }else if(Z>0){
                    Z--;
                }else{
                    buy = "No";
                    break;
                }
           }
            else if(A[i]<5000){
                int tmp_X=A[i]/1000;
                if(A[i]%1000!=0){
                    tmp_X++;
                }
                
                if(X>=tmp_X){
                    X -= tmp_X;
                }else if(Y>0){
                    Y--;
                }else if(Z>0){
                    Z--;
                }else{
                    buy = "No";
                    break;
                }
            }else if(A[i]<10000){
                if(X>0){
                    A[i]-=5000;
                    X--;
                }
                int tmp_X=A[i]/1000;
                if(A[i]%1000!=0){
                    tmp_X++;
                }

                if(X>=tmp_X){
                    X -= tmp_X;
                }else if(Y>1){
                    Y-=2;
                }else if(Z>0){
                    Z--;
                }else{
                    buy = "No";
                    break;
                }
            }else{
                int tmp_Z = A[i]/10000;
                if(Z>=tmp_Z){
                    Z -= tmp_Z;
                }else{
                    buy = "No";                    
                    break;
                }
                int amari_Z = A[i]%10000;
                if(Y>0 && amari_Z>=5000){
                    Y--;
                    amari_Z -= 5000;
                }
                int tmp_X=amari_Z/1000;
                if(amari_Z%1000!=0){
                    tmp_X++;
                }
                
                if(X>=tmp_X){
                    X -= tmp_X;
                }else if(Y>0){
                    Y--;
                }else if(Z>0){
                    Z--;
                }else{
        out.println("5 "+ A[i]);
                    buy = "No";
                    break;
                }
            }
        }

        out.println(buy);
	}

	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}
0