Zombie_PG
@Zombie_PG (ゾンビ)

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

AtCoder Beginner Contest 011-Cを解きたい(Java)

解決したいこと

ABC011のC問題を通したい。

テストケース記載のサイトを参考にしようとしたのですが載っておらず。。。

下記、実ソース

298以上の時に何らかの条件を達成するとNOになるように組んでいるのですが、この通りあと何個か通らないです。
「答えのソース」というより、「足りていないテストパターン」を教えていただきたいです。

image.png

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();

        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(scan.nextInt());
        list.add(scan.nextInt());
        list.add(scan.nextInt());
        Collections.sort(list, Collections.reverseOrder());

        boolean flg = true;
        if(N <= 3){
            flg = true;
        } else if(N >= 4){
            if(list.get(0) <= N && Math.decrementExact(list.get(0)) == list.get(1) && Math.decrementExact(list.get(1)) == list.get(2)){
                System.out.println("abc");
                flg = false;
            } else if(N <= 297){
                flg = true;
            } else if(N >= 298){
                for(int i = 1; i <= 100; i++){
                    N = N - 3;
                    if(N <= 0){
                        flg = true;
                        break;
                    } else if(N >= 0){
                        if(i == 100){
                            flg = false;
                            break;                                
                        }                        
                        if(N == list.get(0) || N == list.get(1) || N == list.get(2)){
                            N = N + 1;
                            if(N == list.get(0) || N == list.get(1) || N == list.get(2)){
                                N = N + 1;
                            }
                            continue;
                        }
                    }
                }
            }
        } 

        if(flg == true){
            System.out.println("YES");
        } else if(flg == false){
            System.out.println("NO");
        }
    }
}
0

1Answer

例えば、test_84_34_64_36.txt

N = 84
NG1 = 34
NG2 = 64
NG3 = 36

と思われますので、進めてみてはいかがでしょうか。

0Like

Comments

  1. @Zombie_PG

    Questioner

    ありがとうございます。
    解くことができました!

Your answer might help someone💌