Submission #932267
Source Code Expand
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; import java.util.function.BiFunction; public class Main { Scanner sc = new Scanner(System.in); public static void main(String[] args) { new Main().run(); } long div(long a, long b) { return a / b + (a % b == 0 ? 0 : 1); } void run() { int n = ni(); long T = 1; long A = 1; long t_ = 1; long a_ = 1; for (int i = 0; i < n; ++i) { long t = ni(); long a = ni(); long v = Math.max(div(T, t), div(A, a)); T = t * v; A = a * v; // debug(t, a, v, T, A); } System.out.println(A + T); } int ni() { return Integer.parseInt(sc.next()); } void debug(Object... os) { System.err.println(Arrays.deepToString(os)); } class BIT<T> { int n; ArrayList<T> bit; BiFunction<T, T, T> bif; BIT(int n, BiFunction<T, T, T> bif, T defaultValue) { this.n = n; bit = new ArrayList<>(n + 1); for (int i = 0; i < n + 1; ++i) { bit.add(defaultValue); } this.bif = bif; } void update(int i, T v) { for (int x = i; x <= n; x += x & -x) { bit.set(x, bif.apply(bit.get(x), v)); } } T reduce(int i, T defaultValue) { T ret = defaultValue; for (int x = i; x > 0; x -= x & -x) { ret = bif.apply(ret, bit.get(x)); } return ret; } } }
Submission Info
Submission Time | |
---|---|
Task | C - AtCoDeer and Election Report |
User | arukuka |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 1488 Byte |
Status | AC |
Exec Time | 169 ms |
Memory | 12704 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 126 ms | 9552 KB |
0_001.txt | AC | 121 ms | 9552 KB |
0_002.txt | AC | 122 ms | 9684 KB |
1_003.txt | AC | 124 ms | 9680 KB |
1_004.txt | AC | 169 ms | 12704 KB |
1_005.txt | AC | 141 ms | 9812 KB |
1_006.txt | AC | 146 ms | 9936 KB |
1_007.txt | AC | 131 ms | 9808 KB |
1_008.txt | AC | 140 ms | 9804 KB |
1_009.txt | AC | 137 ms | 9552 KB |
1_010.txt | AC | 125 ms | 9556 KB |
1_011.txt | AC | 137 ms | 9680 KB |
1_012.txt | AC | 137 ms | 9676 KB |
1_013.txt | AC | 166 ms | 12028 KB |
1_014.txt | AC | 168 ms | 12408 KB |