結果

問題 No.740 幻の木
ユーザー niiminiimi
提出日時 2018-10-05 21:30:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 992 bytes
コンパイル時間 1,311 ms
コンパイル使用メモリ 159,420 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 17:01:08
合計ジャッジ時間 1,847 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 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 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef unsigned long long ll;
typedef std::pair<int, int> P;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define All(i, x) for(typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define ReAll(i, x) for(typeof(x.end()) i = x.end(); i != x.begin(); i--)
#define pb push_back

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX = 100000;
const int INF = 1e9;
const int MOD = 1000000007;
const string END = "\n";

void solve(){
	int n, m, p, q; cin >> n >> m >> p >> q;
	int a[12] = {};
	For(i, 1, 13){
		if(i >= p && i <= p + q - 1){
			a[i-1] = m * 2;
		}else{
			a[i-1] = m;
		}
	}
	bool flag = false;
	int ans = 0;
	while(n > 0){
		Rep(i, 12){
			if(flag) break;
			n -= a[i];
			ans += 1;
			if(n <= 0) flag = true;
		}
	}
	cout << ans << END;
}

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