結果

問題 No.1570 Blocks
ユーザー tentententen
提出日時 2021-06-29 08:38:44
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,571 bytes
コンパイル時間 2,424 ms
コンパイル使用メモリ 74,960 KB
実行使用メモリ 62,484 KB
最終ジャッジ日時 2023-09-08 00:09:51
合計ジャッジ時間 15,044 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,620 KB
testcase_01 AC 42 ms
49,648 KB
testcase_02 AC 232 ms
57,216 KB
testcase_03 AC 334 ms
62,052 KB
testcase_04 AC 213 ms
56,400 KB
testcase_05 AC 225 ms
57,248 KB
testcase_06 AC 285 ms
60,312 KB
testcase_07 AC 119 ms
55,352 KB
testcase_08 AC 304 ms
58,528 KB
testcase_09 AC 340 ms
62,016 KB
testcase_10 AC 244 ms
57,844 KB
testcase_11 AC 255 ms
59,400 KB
testcase_12 AC 357 ms
61,932 KB
testcase_13 AC 263 ms
61,412 KB
testcase_14 AC 266 ms
61,264 KB
testcase_15 AC 195 ms
56,148 KB
testcase_16 AC 273 ms
61,700 KB
testcase_17 AC 230 ms
56,320 KB
testcase_18 AC 249 ms
58,084 KB
testcase_19 AC 227 ms
55,704 KB
testcase_20 AC 201 ms
56,036 KB
testcase_21 AC 307 ms
59,012 KB
testcase_22 AC 41 ms
49,820 KB
testcase_23 AC 43 ms
49,652 KB
testcase_24 AC 43 ms
49,664 KB
testcase_25 AC 41 ms
49,608 KB
testcase_26 AC 43 ms
49,868 KB
testcase_27 AC 43 ms
49,600 KB
testcase_28 AC 44 ms
49,720 KB
testcase_29 AC 43 ms
50,088 KB
testcase_30 AC 42 ms
49,628 KB
testcase_31 AC 43 ms
49,768 KB
testcase_32 AC 246 ms
60,072 KB
testcase_33 AC 389 ms
62,484 KB
testcase_34 AC 264 ms
60,960 KB
testcase_35 AC 366 ms
62,168 KB
testcase_36 AC 264 ms
61,444 KB
testcase_37 AC 355 ms
62,060 KB
testcase_38 WA -
testcase_39 AC 273 ms
61,304 KB
testcase_40 AC 266 ms
59,036 KB
testcase_41 AC 356 ms
62,092 KB
testcase_42 AC 278 ms
61,100 KB
testcase_43 AC 271 ms
61,384 KB
testcase_44 AC 270 ms
61,532 KB
testcase_45 AC 265 ms
61,452 KB
testcase_46 AC 257 ms
58,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        PriorityQueue<Block> blocks = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            blocks.add(new Block(sc.nextInt(), sc.nextInt()));
        }
        long weight = 0;
        while (blocks.size() > 0) {
            Block b = blocks.poll();
            if (weight > b.limit) {
                System.out.println("No");
                return;
            }
            weight += b.weight;
        }
        System.out.println("Yes");
    }
    
    static class Block implements Comparable<Block> {
        int weight;
        int limit;
        
        public Block(int weight, int limit) {
            this.weight = weight;
            this.limit = limit;
        }
        
        public int compareTo(Block b) {
            return limit - b.limit;
        }
    }
}


class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0