結果
問題 | No.2008 Super Worker |
ユーザー | tenten |
提出日時 | 2022-07-20 08:40:51 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 868 ms / 2,000 ms |
コード長 | 1,920 bytes |
コンパイル時間 | 3,725 ms |
コンパイル使用メモリ | 78,332 KB |
実行使用メモリ | 60,936 KB |
最終ジャッジ日時 | 2024-07-02 12:07:37 |
合計ジャッジ時間 | 15,717 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 51 ms
37,068 KB |
testcase_01 | AC | 51 ms
37,080 KB |
testcase_02 | AC | 51 ms
37,188 KB |
testcase_03 | AC | 52 ms
36,948 KB |
testcase_04 | AC | 51 ms
36,696 KB |
testcase_05 | AC | 52 ms
36,572 KB |
testcase_06 | AC | 53 ms
37,096 KB |
testcase_07 | AC | 53 ms
37,096 KB |
testcase_08 | AC | 52 ms
37,048 KB |
testcase_09 | AC | 52 ms
37,056 KB |
testcase_10 | AC | 52 ms
36,732 KB |
testcase_11 | AC | 52 ms
36,908 KB |
testcase_12 | AC | 51 ms
37,052 KB |
testcase_13 | AC | 79 ms
38,328 KB |
testcase_14 | AC | 84 ms
38,308 KB |
testcase_15 | AC | 81 ms
38,212 KB |
testcase_16 | AC | 83 ms
38,584 KB |
testcase_17 | AC | 85 ms
38,200 KB |
testcase_18 | AC | 92 ms
39,052 KB |
testcase_19 | AC | 74 ms
38,208 KB |
testcase_20 | AC | 78 ms
38,336 KB |
testcase_21 | AC | 85 ms
38,476 KB |
testcase_22 | AC | 84 ms
38,412 KB |
testcase_23 | AC | 664 ms
59,968 KB |
testcase_24 | AC | 758 ms
60,004 KB |
testcase_25 | AC | 781 ms
60,340 KB |
testcase_26 | AC | 737 ms
59,924 KB |
testcase_27 | AC | 792 ms
59,640 KB |
testcase_28 | AC | 868 ms
60,808 KB |
testcase_29 | AC | 756 ms
60,936 KB |
testcase_30 | AC | 784 ms
59,724 KB |
testcase_31 | AC | 818 ms
59,660 KB |
testcase_32 | AC | 795 ms
59,884 KB |
testcase_33 | AC | 388 ms
58,076 KB |
testcase_34 | AC | 839 ms
60,284 KB |
testcase_35 | AC | 357 ms
57,496 KB |
ソースコード
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(); } }