Submission #929469


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

// template {{{
/* vim: set foldmethod=marker: */

//
//
//
//  /#######                            /##                               /##
// | ##__  ##                          | ##                              |__/
// | ##  \ ##  /######   /######   /#######  /######   /######   /######  /## /#######
// | #######/ /##__  ## |____  ## /##__  ## |____  ## /##__  ## |____  ##| ##| ##__  ##
// | ##__  ##| ##  \ ##  /#######| ##  | ##  /#######| ##  \ ##  /#######| ##| ##  \ ##
// | ##  \ ##| ##  | ## /##__  ##| ##  | ## /##__  ##| ##  | ## /##__  ##| ##| ##  | ##
// | ##  | ##|  ######/|  #######|  #######|  #######|  #######|  #######| ##| ##  | ##
// |__/  |__/ \______/  \_______/ \_______/ \_______/ \____  ## \_______/|__/|__/  |__/
//                                                    /##  \ ##
//                                                   |  ######/
//                                                    \______/

// constant
const int    INF = (int)1e9;
const int    MOD = (int)1e9 + 7;
const double PI  = acos(-1);
const double EPS = 1e-14;

// typedef
using ll   = long long;
using ull  = unsigned long long;
using vi   = vector<int>;
using vl   = vector<ll>;
using vd   = vector<double>;
using pii  = pair<int, int>;
using pdd  = pair<double, double>;
using vec2 = complex<double>;

// repetition
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define RFOR(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPIT(i, obj) for (auto i = (obj).begin(); i != (obj).end(); i++)
#define RREPIT(i, obj) for (auto i = (obj).rbegin(); i != (obj).rend(); i++)

// short
#define pb emplace_back
#define mp make_pair
#define fst first
#define sec second

// input
template <class T = int> inline T in(){ T x; cin >> x; return x; }
template <class T = int> inline vector<T> in(int n){ vector<T> v(n); REP(i, n) v[i] = in<T>(); return v; }
template <class T = int> inline void in(T* x, int n){ REP(i, n) x[i] = in<T>(); }
#define inl in<ll>
#define ind in<double>
#define ins in<string>

// container util
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define SZ(obj) obj.size()
#define SZA(ary) (sizeof(ary) / sizeof(*ary))
#define SORT(obj) sort(all(obj))
#define EXIST(obj, key) ((obj).find(key) != (obj).end())
#define CLEARY(ary) memset((ary), 0, sizeof(ary))

// print util
#define PRINT(x) cout << (x) << endl
#define PRINTD(x, d) cout << fixed << setprecision(d) << (x) << endl
template <class T> inline void printv(vector<T>& v){ int n = sz(v); REP(i, n) cout << v[i] << "\n "[i < n - 1]; }
template <class T> inline void printv(vector<T>& v, int n){ REP(i, n) cout << v[i] << "\n "[i < n - 1]; }
template <class T> inline void printa(T* ary, int n){ REP(i, n) cout << ary[i] << "\n "[i < n - 1]; }
#define DUMP(x) cerr << #x << ": " << (x) << endl
#define DEBUG(x) cerr << #x << ": " << (x) << " (" << __LINE__ << ")" << endl

//template }}}

signed main()
{
    int n = in();

    ull ts = in(), as = in();
    REP(i, n - 1){
        int t = in(), a = in();
        ull mt = ts / t + !!(ts % t);
        ull ma = as / a + !!(as % a);

        ts = t * max(mt, ma);
        as = a * max(mt, ma);
        // printf(" %d %d %d\n", ts, as, ts + as);
    }
    PRINT(ts + as);

    return 0;
}

Submission Info

Submission Time
Task C - AtCoDeer and Election Report
User ringoh72
Language C++14 (GCC 5.4.1)
Score 300
Code Size 3494 Byte
Status AC
Exec Time 3 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 15
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 256 KB
0_001.txt AC 2 ms 256 KB
0_002.txt AC 2 ms 256 KB
1_003.txt AC 2 ms 256 KB
1_004.txt AC 3 ms 256 KB
1_005.txt AC 3 ms 256 KB
1_006.txt AC 3 ms 256 KB
1_007.txt AC 3 ms 256 KB
1_008.txt AC 3 ms 256 KB
1_009.txt AC 3 ms 256 KB
1_010.txt AC 3 ms 256 KB
1_011.txt AC 3 ms 256 KB
1_012.txt AC 3 ms 256 KB
1_013.txt AC 3 ms 256 KB
1_014.txt AC 3 ms 256 KB