結果
| 問題 |
No.281 門松と魔法(1)
|
| ユーザー |
chakku
|
| 提出日時 | 2016-11-05 18:20:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,739 bytes |
| コンパイル時間 | 1,551 ms |
| コンパイル使用メモリ | 171,056 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-25 03:10:00 |
| 合計ジャッジ時間 | 4,181 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 WA * 22 RE * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
/*{{{*/ //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/
int main(){
ll d;
vector<ll> h(3);
cin>>d;
rep(i,3) cin>>h[i];
if(h[0]==0 and h[1] == 0 and h[2]==0){
cout << -1 << endl;
return 0;
}
ll ans=0;
if(h[0]==h[2]){
ans++;
h[2]-=d;
}
if(h[0]!=h[1] and h[1]!=h[2]){
if(h[0]>h[1] and h[2]>h[1]){
cout << ans << endl;
return 0;
}else if(h[0] > h[1] and h[1] > h[2]){
cout << ans << endl;
return 0;
}
}
if(h[0] > h[2]) swap(h[0],h[2]);
ll m = h[0]-1;
ll d1 = ((h[1]-m)+d-1)/d;
ll m2=h[1]-1;
ll d2 = ((h[2]-m2)+d-1)/d;
debug(h);
debug2(d1,d2);
cout << min(d1,d2)+ans << endl;
}
chakku