hwangnk1004 / Algorithm

0 stars 0 forks source link

StepByStep #짧은노래 #283

Open hwangnk1004 opened 4 years ago

hwangnk1004 commented 4 years ago

import java.util.Scanner;

public class Main { public static void main(String args[]) {

    Scanner scanner = new Scanner(System.in);

    int n = scanner.nextInt();
    int q = scanner.nextInt();

    int arr[] = new int[120*n];

    int acc = 0;
    int k = 1;

    for (int i = 1; i <= n; i++) {
        int count = scanner.nextInt();
        int x = 0;

        while (true) {
            if (count == x++) {
                k++;
                break;
            }

            arr[acc++] = k;

        }
    }

    for (int i = 0; i < q; i++) {
        System.out.println(arr[scanner.nextInt()]);
    }

}

}