結果
問題 | No.281 門松と魔法(1) |
ユーザー | ともき |
提出日時 | 2015-10-12 11:27:34 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,598 bytes |
コンパイル時間 | 1,206 ms |
コンパイル使用メモリ | 119,116 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-06 19:45:04 |
合計ジャッジ時間 | 2,507 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 2 ms
6,820 KB |
testcase_02 | AC | 2 ms
6,820 KB |
testcase_03 | AC | 2 ms
6,820 KB |
testcase_04 | WA | - |
testcase_05 | AC | 2 ms
6,820 KB |
testcase_06 | AC | 2 ms
6,816 KB |
testcase_07 | AC | 1 ms
6,816 KB |
testcase_08 | AC | 2 ms
6,820 KB |
testcase_09 | AC | 2 ms
6,816 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 2 ms
6,820 KB |
testcase_15 | AC | 2 ms
6,816 KB |
testcase_16 | AC | 2 ms
6,816 KB |
testcase_17 | AC | 2 ms
6,820 KB |
testcase_18 | AC | 2 ms
6,820 KB |
testcase_19 | AC | 2 ms
6,816 KB |
testcase_20 | AC | 2 ms
6,816 KB |
testcase_21 | AC | 2 ms
6,816 KB |
testcase_22 | AC | 2 ms
6,816 KB |
testcase_23 | AC | 2 ms
6,816 KB |
testcase_24 | AC | 2 ms
6,816 KB |
testcase_25 | AC | 2 ms
6,816 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 2 ms
6,820 KB |
testcase_30 | AC | 2 ms
6,820 KB |
testcase_31 | AC | 2 ms
6,816 KB |
testcase_32 | AC | 2 ms
6,820 KB |
testcase_33 | AC | 2 ms
6,816 KB |
testcase_34 | AC | 2 ms
6,816 KB |
testcase_35 | AC | 1 ms
6,820 KB |
testcase_36 | AC | 2 ms
6,816 KB |
testcase_37 | AC | 2 ms
6,820 KB |
testcase_38 | AC | 2 ms
6,820 KB |
testcase_39 | AC | 2 ms
6,816 KB |
testcase_40 | AC | 2 ms
6,816 KB |
testcase_41 | AC | 2 ms
6,820 KB |
testcase_42 | AC | 2 ms
6,820 KB |
testcase_43 | AC | 2 ms
6,816 KB |
testcase_44 | AC | 2 ms
6,816 KB |
testcase_45 | AC | 2 ms
6,816 KB |
testcase_46 | AC | 2 ms
6,820 KB |
testcase_47 | AC | 2 ms
6,816 KB |
testcase_48 | AC | 2 ms
6,816 KB |
testcase_49 | AC | 1 ms
6,820 KB |
testcase_50 | AC | 2 ms
6,820 KB |
testcase_51 | AC | 1 ms
6,816 KB |
testcase_52 | AC | 2 ms
6,820 KB |
testcase_53 | AC | 2 ms
6,820 KB |
testcase_54 | AC | 1 ms
6,820 KB |
testcase_55 | WA | - |
testcase_56 | AC | 2 ms
6,816 KB |
ソースコード
#include <iostream> #include <iomanip> #include <vector> #include <valarray> #include <map> #include <set> #include <list> #include <queue> #include <stack> #include <bitset> #include <utility> #include <numeric> #include <algorithm> #include <functional> #include <complex> #include <string> #include <sstream> #include <cstdio> #include <cstdlib> #include <cctype> #include <cstring> #include <cassert> #include <unordered_set> #include <unordered_map> #include <random> #include <thread> #include <chrono> using namespace std; #define int long long #define let const auto #define var auto #define all(c) c.begin(), c.end() #define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define dump(x) #endif typedef complex<double> point; template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; for(auto it = v.begin(); it != v.end(); ++it){ if(it != v.begin()){ os << ","; } os << *it; } return os << "}"; } template<typename T> void isort(std::vector<T>& v, std::function<bool(T,T)> comp=less<T>()){ sort(v.begin(), v.end(), comp); } template<typename T> std::vector<T> sort(std::vector<T> v, std::function<bool(T,T)> comp=less<T>()){ isort(v); return v; } template<typename T1, typename T2> std::vector<T2> rmap(const std::vector<T1>& v, std::function<T2(T1)> f){ std::vector<T2> t; t.reserve(v.size()); for(const auto& i: v) t.push_back(f(i)); return t; } std::vector<std::string> split(std::string str, char delim){ std::vector<std::string> res; size_t current = 0, found; while((found = str.find_first_of(delim, current)) != std::string::npos){ res.push_back(std::string(str, current, found - current)); current = found + 1; } res.push_back(std::string(str, current, str.size() - current)); return res; } string join(const std::vector<string>& v, string delim){ string ret = ""; for(auto it = v.begin(); it != v.end(); ++it){ if(it != v.begin()){ ret += delim; } ret += *it; } return ret; } int min_solve(int d, vector<int> h){ int ret = 0; if(h[0] == h[2]){ ret++; h[0] -= d; } int diff = h[1] - min(h[0], h[2]); if(diff < 0) return ret; int needs = (diff / d) + 1; h[1] -= d * needs; if(h[0] >= 0 && h[1] >= 0 && h[2] >= 0) return ret + needs; else return -1; } int max_solve(int d, vector<int> h){ int ret = 0; vector<int> k = {0,2}; for(int i : k){ int diff = h[i] - h[1]; if(diff >= 0){ int needs = (diff / d) + 1; ret += needs; h[i] -= d * needs; } } if(h[0] == h[2]){ ret++; h[0] -= d; } if(h[0] >= 0 && h[1] >= 0 && h[2] >= 0) return ret; else return -1; } int solve(int d, vector<int> h){ if((h[0] != h[1] && h[1] != h[2] && h[0] != h[2]) && ((h[0] < h[1] && h[1] > h[2]) || (h[0] > h[1] && h[1] < h[2]))) return 0; if(d == 0) return -1; int mis = min_solve(d,h); int mas = max_solve(d,h); if(mis == -1 && mas == -1) return -1; if(mis == -1) return mas; if(mas == -1) return mis; return min(mis,mas); } signed main() { ios::sync_with_stdio(false); cin.tie(0); int d; cin >> d; vector<int> h(3); for(int& i: h) cin >> i; cout << solve(d, h) << endl; return 0; }