結果

問題 No.2008 Super Worker
ユーザー tentententen
提出日時 2022-07-20 08:40:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 833 ms / 2,000 ms
コード長 1,920 bytes
コンパイル時間 2,109 ms
コンパイル使用メモリ 74,824 KB
実行使用メモリ 73,888 KB
最終ジャッジ日時 2023-09-15 07:47:41
合計ジャッジ時間 15,934 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,908 KB
testcase_01 AC 43 ms
49,532 KB
testcase_02 AC 46 ms
49,552 KB
testcase_03 AC 47 ms
49,828 KB
testcase_04 AC 46 ms
49,564 KB
testcase_05 AC 43 ms
49,668 KB
testcase_06 AC 43 ms
49,820 KB
testcase_07 AC 43 ms
49,644 KB
testcase_08 AC 43 ms
49,540 KB
testcase_09 AC 43 ms
49,604 KB
testcase_10 AC 43 ms
49,788 KB
testcase_11 AC 43 ms
49,932 KB
testcase_12 AC 43 ms
49,604 KB
testcase_13 AC 59 ms
50,676 KB
testcase_14 AC 75 ms
50,716 KB
testcase_15 AC 73 ms
50,756 KB
testcase_16 AC 67 ms
50,644 KB
testcase_17 AC 68 ms
50,620 KB
testcase_18 AC 87 ms
52,576 KB
testcase_19 AC 66 ms
50,656 KB
testcase_20 AC 70 ms
50,760 KB
testcase_21 AC 69 ms
52,060 KB
testcase_22 AC 64 ms
51,852 KB
testcase_23 AC 787 ms
71,528 KB
testcase_24 AC 682 ms
71,140 KB
testcase_25 AC 703 ms
71,612 KB
testcase_26 AC 819 ms
70,936 KB
testcase_27 AC 729 ms
70,544 KB
testcase_28 AC 833 ms
72,132 KB
testcase_29 AC 743 ms
71,428 KB
testcase_30 AC 700 ms
71,740 KB
testcase_31 AC 764 ms
71,456 KB
testcase_32 AC 801 ms
71,428 KB
testcase_33 AC 370 ms
70,812 KB
testcase_34 AC 784 ms
73,888 KB
testcase_35 AC 338 ms
68,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        Work[] works = new Work[n];
        for (int i = 0; i < n; i++) {
            works[i] = new Work(sc.nextInt());
        }
        for (int i = 0; i < n; i++) {
            works[i].b = sc.nextInt();
        }
        Arrays.sort(works);
        long base = 1;
        long income = 0;
        for (Work x : works) {
            income += x.a * base % MOD;
            income %= MOD;
            base *= x.b;
            base %= MOD;
        }
        System.out.println(income);
    }
    
    static class Work implements Comparable<Work> {
        long a;
        long b;
        
        public Work(long a) {
            this.a = a;
        }
        
        public int compareTo(Work another) {
            long left = a + b * another.a;
            long right = another.a + another.b * a;
            if (left == right) {
                return 0;
            } else if (left < right) {
                return 1;
            } else {
                return -1;
            }
        }
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    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 String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0