Submission #1535544
Source Code Expand
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long double ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int a1, a2;
cin >> a1 >> a2;
ll atotal = a1, btotal = a2;
for (int i = 1; i < n; ++i) {
int a, b;
cin >> a >> b;
ll low = 0, high = 1e18, cnt = 100;
while (cnt--) {
ll mid = floor((low+high)/2);
ll a1 = a*mid, b1 = b*mid;
if (a1 >= atotal && b1 >= btotal) high = mid;
else low = mid+1;
}
atotal = a*high, btotal = b*high;
}
cout << fixed << setprecision(0);
cout << atotal+btotal << "\n";
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - AtCoDeer and Election Report |
| User | Quinas |
| Language | C++14 (GCC 5.4.1) |
| Score | 300 |
| Code Size | 875 Byte |
| Status | AC |
| Exec Time | 4 ms |
| Memory | 512 KiB |
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 | 3 ms | 512 KiB |
| 0_001.txt | AC | 1 ms | 256 KiB |
| 0_002.txt | AC | 1 ms | 256 KiB |
| 1_003.txt | AC | 1 ms | 256 KiB |
| 1_004.txt | AC | 4 ms | 256 KiB |
| 1_005.txt | AC | 2 ms | 256 KiB |
| 1_006.txt | AC | 2 ms | 256 KiB |
| 1_007.txt | AC | 2 ms | 256 KiB |
| 1_008.txt | AC | 1 ms | 256 KiB |
| 1_009.txt | AC | 1 ms | 256 KiB |
| 1_010.txt | AC | 1 ms | 256 KiB |
| 1_011.txt | AC | 1 ms | 256 KiB |
| 1_012.txt | AC | 1 ms | 256 KiB |
| 1_013.txt | AC | 4 ms | 256 KiB |
| 1_014.txt | AC | 4 ms | 256 KiB |