結果

問題 No.846 メダル
ユーザー @abcde@abcde
提出日時 2019-08-23 17:39:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 996 bytes
コンパイル時間 1,725 ms
コンパイル使用メモリ 161,272 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 15:39:45
合計ジャッジ時間 2,175 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    
    // 1. 入力情報取得.
    LL P, Q, R, A, B, C;
    scanf("%lld %lld %lld %lld %lld %lld", &P, &Q, &R, &A, &B, &C);
    
    // 2. メダルの授与状況を基に, 参加者の総数 N を 推定.
    bool ok = true;
    
    // 2-1. 金 ~ 銅メダル.
    LL minGSB = 0, maxGSB = 0;
    minGSB = R * (A + B + C - 1) + 1;
    maxGSB = R * (A + B + C);
    
    // 2-2. 金 ~ 銀メダル.
    LL minGS = 0, maxGS = 0;
    minGS = Q * (A + B - 1) + 1;
    maxGS = Q * (A + B);
    
    // 2-3. 金メダル.
    LL minG = 0, maxG = 0;
    minG = P * (A - 1) + 1;
    maxG = P * A;
    
    // 3. 参加者の総数 N を 計算.
    LL minN = 0, maxN = 1e9;
    minN = max(max(minGSB, minGS), minG);
    maxN = min(min(maxGSB, maxGS), maxG);
    if(minN > maxN) ok = false;
    
    // 4. 後処理.
    if(ok) printf("%lld %lld\n", minN, maxN);
    else   printf("%d\n", -1);
    return 0;
    
}
0