結果

問題 No.2462 七人カノン
ユーザー tentententen
提出日時 2023-09-19 16:56:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 502 ms / 2,000 ms
コード長 2,371 bytes
コンパイル時間 4,799 ms
コンパイル使用メモリ 80,884 KB
実行使用メモリ 68,840 KB
最終ジャッジ日時 2023-09-19 16:56:47
合計ジャッジ時間 21,041 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
51,708 KB
testcase_01 AC 65 ms
51,684 KB
testcase_02 AC 65 ms
51,496 KB
testcase_03 AC 108 ms
52,824 KB
testcase_04 AC 100 ms
52,996 KB
testcase_05 AC 98 ms
52,880 KB
testcase_06 AC 100 ms
52,860 KB
testcase_07 AC 98 ms
52,848 KB
testcase_08 AC 96 ms
52,036 KB
testcase_09 AC 101 ms
52,020 KB
testcase_10 AC 107 ms
53,296 KB
testcase_11 AC 103 ms
52,860 KB
testcase_12 AC 102 ms
52,952 KB
testcase_13 AC 423 ms
64,252 KB
testcase_14 AC 451 ms
64,016 KB
testcase_15 AC 444 ms
63,972 KB
testcase_16 AC 457 ms
66,424 KB
testcase_17 AC 449 ms
63,800 KB
testcase_18 AC 149 ms
57,256 KB
testcase_19 AC 147 ms
56,516 KB
testcase_20 AC 468 ms
67,656 KB
testcase_21 AC 480 ms
67,844 KB
testcase_22 AC 478 ms
68,840 KB
testcase_23 AC 484 ms
68,220 KB
testcase_24 AC 375 ms
66,420 KB
testcase_25 AC 502 ms
68,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int q = sc.nextInt();
        int[] imos = new int[100002];
        int[] idxes = new int[q];
        int[] lefts = new int[q];
        int[] rights = new int[q];
        for (int i = 0; i < q; i++) {
            idxes[i] = sc.nextInt() - 1;
            lefts[i] = sc.nextInt();
            rights[i] = sc.nextInt();
            imos[lefts[i] + 1]++;
            imos[rights[i] + 1]--;
        }
        double[] sums = new double[100001];
        for (int i = 1; i <= 100000; i++) {
            sums[i] = sums[i - 1];
            imos[i] += imos[i - 1];
            if (imos[i] > 0) {
                sums[i] += 1.0 / imos[i];
            }
        }
        double[] ans = new double[n];
        for (int i = 0; i < q; i++) {
            ans[idxes[i]] += sums[rights[i]] - sums[lefts[i]]; 
        }
        System.out.println(String.join("\n", Arrays.stream(ans).mapToObj(String::valueOf).toArray(String[]::new)));
    }
} 
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0