結果

問題 No.281 門松と魔法(1)
ユーザー otsnskotsnsk
提出日時 2015-09-29 19:27:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,353 bytes
コンパイル時間 654 ms
コンパイル使用メモリ 66,396 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-24 11:55:13
合計ジャッジ時間 1,956 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 1 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 1 ms
6,940 KB
testcase_28 AC 1 ms
6,940 KB
testcase_29 AC 1 ms
6,940 KB
testcase_30 WA -
testcase_31 AC 1 ms
6,940 KB
testcase_32 AC 2 ms
6,940 KB
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 1 ms
6,944 KB
testcase_35 AC 2 ms
6,940 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 2 ms
6,940 KB
testcase_46 WA -
testcase_47 AC 2 ms
6,940 KB
testcase_48 WA -
testcase_49 WA -
testcase_50 AC 2 ms
6,940 KB
testcase_51 AC 1 ms
6,940 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 1 ms
6,944 KB
testcase_56 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:52:21: warning: ‘l’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   52 |         int n = (h[l]-h[1])/d + 1;
      |                     ^
main.cpp:48:17: warning: ‘s’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   48 |     else if (h[s] == 0 && h[1] == 0) {
      |                 ^

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

#define FORR(i,b,e) for(int i=(b);i<(int)(e);++i)
#define FOR(i,e) FORR(i,0,e)
#define sortuniq(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(),v.end()),v.end())
#define dump(var) cerr << #var ": " << var << "\n"
#define dumpc(con) for(auto& e: con) cerr << e << " "; cerr<<"\n"

typedef long long ll;
typedef unsigned long long ull;

const double EPS = 1e-6;
const int d4[] = {0, -1, 0, 1, 0};

using namespace std;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int d;
    cin >> d;

    vector<int> h(3);
    int s, ss=1e9+1, l, ls=-1;
    FOR(i, 3) {
        cin >> h[i];
        if (h[i] < ss) {
            ss = h[i];
            s = i;
        }
        if (h[i] > ls) {
            ls = h[i];
            l = i;
        }
    }
    
    if (s == 1 || l == 1) {
        cout << 0 << endl;
    }
    else if (d == 0) {
        cout << -1 << endl;
    }
    else if (h[s] == 0 && h[1] == 0) {
        cout << -1 << endl;
    }
    else if (h[s] == 0) {
        int n = (h[l]-h[1])/d + 1;
        int xl = max(0, h[l] - n*d);
        if (xl == 0) cout << -1 << endl;
        else {
            cout << n << endl;
        }
    }
    else {
        int mind = min(h[1]-h[s], h[l]-h[1]);
        cout << mind/d + 1 << endl;
    }

    return 0;
}
0