Submission #55263558


Source Code Expand

// import static java.lang.Math.abs;
// import java.util.*;
// public class Main {
//     public static void main(String[] args) {
//         Scanner sc = new Scanner(System.in);
//         long sX = Long.parseLong(sc.next());
//         long sY = Long.parseLong(sc.next());
//         long tX = Long.parseLong(sc.next());
//         long tY = Long.parseLong(sc.next());
//         long Y = tY - sY;
//         long costY = abs(Y);
//         long x = tX - sX;
//         int advantage = 0;
//         if (sX > tX) {
//             if ((sX - 1 + sY) % 2 == 0) {
//                 advantage++;
//             }
//             if ((tX + tY) % 2 == 0) {
//                 advantage++;
//             }
//         } else if (sX < tX) {
//             if ((sX + sY) % 2 == 0) {
//                 advantage++;
//             }
//             if ((tX + tY - 1) % 2 == 0) {
//                 advantage++;
//             }
//         }
//         long tempX = 0;
//         if (x - advantage > 0) {
//             if (abs(x - advantage) % 2 == 0) {
//                 tempX = abs(x) / 2;
//             } else {
//                 tempX = abs(x) / 2 + 1;
//             }
//         }
//         long costX = tempX - costY;
//         if (costX < 0) {
//             costX = 0;
//         }
//         long cost = costX + costY;
//         System.out.println(cost);
//     }
// }
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int X = Integer.parseInt(sc.next());
        ArrayList<Integer> A = new ArrayList<>();

        for (int i = 0; i <= N; i++) {
            if (i == K) {
                A.add(X);
            } else {
                A.add(Integer.parseInt(sc.next()));
            }
        }

        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < A.size(); i++) {
            sb.append(A.get(i));
            if (i < A.size() - 1) {
                sb.append(" ");
            }
        }

        System.out.println(sb);
    }
}

Submission Info

Submission Time
Task A - Insert
User andrywawa
Language Java (OpenJDK 17)
Score 100
Code Size 2254 Byte
Status AC
Exec Time 83 ms
Memory 38144 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 18
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt
Case Name Status Exec Time Memory
sample_01.txt AC 72 ms 37924 KiB
sample_02.txt AC 71 ms 37760 KiB
sample_03.txt AC 75 ms 38060 KiB
test_01.txt AC 71 ms 37752 KiB
test_02.txt AC 76 ms 38068 KiB
test_03.txt AC 79 ms 37852 KiB
test_04.txt AC 74 ms 37760 KiB
test_05.txt AC 77 ms 38036 KiB
test_06.txt AC 79 ms 38056 KiB
test_07.txt AC 76 ms 37896 KiB
test_08.txt AC 73 ms 38092 KiB
test_09.txt AC 83 ms 37872 KiB
test_10.txt AC 77 ms 38016 KiB
test_11.txt AC 78 ms 38128 KiB
test_12.txt AC 75 ms 37804 KiB
test_13.txt AC 77 ms 38036 KiB
test_14.txt AC 76 ms 38144 KiB
test_15.txt AC 77 ms 37808 KiB