Submission #7469721


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64

int getNext(int n, int m){
  int tmp = n/m*m;
  return tmp;
}

signed main() {
  int k;cin>>k;
  vector<int> a(k);
  for(int i=k-1;i>=0;--i) cin>>a[i];
  // aは逆に保存している

  int lb=2,ub=2;
  for(int i=0;i<k;++i){
    int tmp = getNext(ub,a[i]);
    if (tmp < lb) {
      cout<<-1<<endl;
      return 0;
    }
    ub = tmp+a[i]-1;

    tmp = getNext(lb,a[i]);
    if(tmp<lb) tmp += a[i];
    lb = tmp;
  }

  cout<<lb<<" "<<ub<<endl;
  
  return 0;
}

Submission Info

Submission Time
Task B - Ice Rink Game
User task4233
Language C++14 (GCC 5.4.1)
Score 500
Code Size 589 Byte
Status
Exec Time 44 ms
Memory 1152 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
× 3
× 33
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt, subtask_1_26.txt, subtask_1_27.txt
Case Name Status Exec Time Memory
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
subtask_1_01.txt 1 ms 256 KB
subtask_1_02.txt 1 ms 256 KB
subtask_1_03.txt 1 ms 256 KB
subtask_1_04.txt 1 ms 256 KB
subtask_1_05.txt 1 ms 256 KB
subtask_1_06.txt 18 ms 1024 KB
subtask_1_07.txt 44 ms 1024 KB
subtask_1_08.txt 1 ms 256 KB
subtask_1_09.txt 1 ms 256 KB
subtask_1_10.txt 3 ms 256 KB
subtask_1_11.txt 42 ms 1024 KB
subtask_1_12.txt 41 ms 1024 KB
subtask_1_13.txt 30 ms 1024 KB
subtask_1_14.txt 41 ms 1024 KB
subtask_1_15.txt 42 ms 1024 KB
subtask_1_16.txt 4 ms 384 KB
subtask_1_17.txt 31 ms 1024 KB
subtask_1_18.txt 31 ms 1024 KB
subtask_1_19.txt 28 ms 896 KB
subtask_1_20.txt 29 ms 1024 KB
subtask_1_21.txt 30 ms 1024 KB
subtask_1_22.txt 29 ms 1024 KB
subtask_1_23.txt 1 ms 256 KB
subtask_1_24.txt 2 ms 256 KB
subtask_1_25.txt 42 ms 1024 KB
subtask_1_26.txt 2 ms 256 KB
subtask_1_27.txt 42 ms 1152 KB