Submission #1973766


Source Code Expand

#include <bits/stdc++.h>

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

// ========================================================================= //

const int N = 100179;

int k, a[N];

int main() {
    scanf("%d", &k);
    for (int i = 0; i < k; ++i)
        scanf("%d", a+i);

    ll n1 = 2, n2 = 2;
    for (int i = k - 1; i >= 0; --i) {
        n2 = n2 / a[i] * a[i];
        n1 += a[i] - 1;
        n1 = n1 / a[i] * a[i];
        if (n1 > n2) {
            cout << "-1\n";
            return 0;
        }
        n2 += a[i] - 1;
    }
    cout << n1 << " " << n2 << "\n";

    return 0;
}

Submission Info

Submission Time
Task B - Ice Rink Game
User SpyCheese
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1530 Byte
Status AC
Exec Time 14 ms
Memory 640 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:39:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &k);
                    ^
./Main.cpp:41:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", a+i);
                         ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 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 AC 1 ms 256 KiB
sample_02.txt AC 1 ms 256 KiB
sample_03.txt AC 1 ms 256 KiB
subtask_1_01.txt AC 1 ms 256 KiB
subtask_1_02.txt AC 1 ms 256 KiB
subtask_1_03.txt AC 1 ms 256 KiB
subtask_1_04.txt AC 1 ms 256 KiB
subtask_1_05.txt AC 1 ms 256 KiB
subtask_1_06.txt AC 10 ms 640 KiB
subtask_1_07.txt AC 13 ms 640 KiB
subtask_1_08.txt AC 1 ms 256 KiB
subtask_1_09.txt AC 1 ms 256 KiB
subtask_1_10.txt AC 2 ms 256 KiB
subtask_1_11.txt AC 14 ms 640 KiB
subtask_1_12.txt AC 14 ms 640 KiB
subtask_1_13.txt AC 12 ms 640 KiB
subtask_1_14.txt AC 13 ms 640 KiB
subtask_1_15.txt AC 14 ms 640 KiB
subtask_1_16.txt AC 2 ms 256 KiB
subtask_1_17.txt AC 13 ms 640 KiB
subtask_1_18.txt AC 13 ms 640 KiB
subtask_1_19.txt AC 11 ms 640 KiB
subtask_1_20.txt AC 11 ms 640 KiB
subtask_1_21.txt AC 11 ms 640 KiB
subtask_1_22.txt AC 11 ms 640 KiB
subtask_1_23.txt AC 1 ms 256 KiB
subtask_1_24.txt AC 1 ms 256 KiB
subtask_1_25.txt AC 14 ms 640 KiB
subtask_1_26.txt AC 1 ms 256 KiB
subtask_1_27.txt AC 14 ms 640 KiB