Submission #53636169


Source Code Expand

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<NamePoint> userInfo = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            int n = Integer.parseInt(sc.next());
            int m = Integer.parseInt(sc.next());
            userInfo.add(new NamePoint(n, m, i + 1));
        }

        ArrayList<Integer> deleteNumber = new ArrayList<>();
        //いらないカードを見極める処理(ハジからどんどんやってく)
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                if (userInfo.get(i).getStrong() > userInfo.get(j).getStrong()
                        && userInfo.get(i).getCost() < userInfo.get(j).getCost()) {
                    deleteNumber.add(j);
                } else if (userInfo.get(i).getStrong() < userInfo.get(j).getStrong()
                        && userInfo.get(i).getCost() > userInfo.get(j).getCost()) {
                    deleteNumber.add(i);
                }

            }
        }
        List<Integer> listWithoutDuplicates = new ArrayList<>(new HashSet<>(deleteNumber));

        Collections.sort(listWithoutDuplicates);
        Collections.reverse(listWithoutDuplicates);

        for (int e : listWithoutDuplicates) {
            if (e <= userInfo.size() - 1) {
                userInfo.remove(e);
            }
        }
        String namesList = extractNames(userInfo);
        System.out.println(userInfo.size());
        System.out.println(namesList);

    }

    public static class NamePoint {

        // メンバ変数
        int strong;
        int cost;
        int number;

        // コンストラクタ
        public NamePoint(int strong, int cost, int number) {
            this.strong = strong;
            this.cost = cost;
            this.number = number;
        }

        // ゲッターとセッター
        public int getStrong() {
            return strong;
        }

        public void setStrong(int name) {
            this.strong = name;
        }

        public int getCost() {
            return cost;
        }

        public void setPoint(int cost) {
            this.cost = cost;
        }

        public int getNumber() {
            return number;
        }

        public void setNumber(int cost) {
            this.number = cost;
        }

    }

    // nameのみを抽出するメソッド
    public static String extractNames(ArrayList<NamePoint> list) {
        StringBuilder sb = new StringBuilder();
        for (NamePoint np : list) {
            if (sb.length() > 0) {
                sb.append(" ");
            }
            sb.append(np.getNumber());
        }
        return sb.toString();
    }
}

Submission Info

Submission Time
Task C - AtCoder Magics
User andrywawa
Language Java (OpenJDK 17)
Score 0
Code Size 3015 Byte
Status TLE
Exec Time 2256 ms
Memory 883860 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 350
Status
AC × 3
AC × 3
TLE × 14
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_hand_00.txt, 01_hand_01.txt, 01_hand_02.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 69 ms 37768 KiB
00_sample_01.txt AC 69 ms 37900 KiB
00_sample_02.txt AC 68 ms 38084 KiB
01_hand_00.txt TLE 2251 ms 847384 KiB
01_hand_01.txt TLE 2211 ms 68036 KiB
01_hand_02.txt TLE 2214 ms 68372 KiB
02_random_00.txt TLE 2255 ms 849580 KiB
02_random_01.txt TLE 2256 ms 883860 KiB
02_random_02.txt TLE 2252 ms 850924 KiB
02_random_03.txt TLE 2230 ms 439376 KiB
02_random_04.txt TLE 2227 ms 374168 KiB
02_random_05.txt TLE 2222 ms 282016 KiB
02_random_06.txt TLE 2243 ms 683620 KiB
02_random_07.txt TLE 2245 ms 724368 KiB
02_random_08.txt TLE 2239 ms 610956 KiB
02_random_09.txt TLE 2239 ms 610732 KiB
02_random_10.txt TLE 2239 ms 615188 KiB