結果

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

テストケース

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

    return 0;
}
0