Submission #927742


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
ll t[1252],a[1252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%lld%lld",t+i,a+i);
  ll x=t[0],y=a[0];
  FOR(i,1,n){
    ll o=t[i],p=a[i];
    ll ro = (x+o-1)/o;
    ll nx = o*ro;
    ll ny = p*ro;
    if(ny>=y){
      x=nx;
      y=ny;
    }else{
      ro = (y+p-1)/p;
      x=o*ro;
      y=p*ro;
    }
  }
  printf("%lld\n",x+y);
  return 0;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:38:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
                 ^
./Main.cpp:39:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   REP(i,n)scanf("%lld%lld",t+i,a+i);
                                    ^

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 2 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 2 ms 256 KB
1_005.txt AC 2 ms 256 KB
1_006.txt AC 2 ms 256 KB
1_007.txt AC 2 ms 256 KB
1_008.txt AC 2 ms 256 KB
1_009.txt AC 2 ms 256 KB
1_010.txt AC 2 ms 256 KB
1_011.txt AC 2 ms 256 KB
1_012.txt AC 2 ms 256 KB
1_013.txt AC 2 ms 256 KB
1_014.txt AC 2 ms 256 KB