結果

問題 No.555 世界史のレポート
ユーザー iwashi31iwashi31
提出日時 2017-08-12 00:14:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 1,448 bytes
コンパイル時間 879 ms
コンパイル使用メモリ 97,572 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-03 00:20:04
合計ジャッジ時間 1,907 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 12 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

set<pair<int, int>> visit;
priority_queue<pair<int, pair<int, int>>> q;

signed main() {
	int N, C, V;
	cin >> N >> C >> V;

	q.push(mp(0, mp(1, 0)));
	while (true) {
		auto now = q.top(); q.pop();
		int nowCost = -now.first;
		int nowLen = now.second.first;
		int nowCopy = now.second.second;
		if (nowLen >= N) {
			cout << nowCost << endl;
			break;
		}
		if (visit.find(now.second) != visit.end()) continue;
		visit.insert(now.second);
		if (nowLen != nowCopy) {
			q.push(mp(-(nowCost + C), mp(nowLen, nowLen)));
		}
		q.push(mp(-(nowCost + V), mp(nowLen + nowCopy, nowCopy)));
	}

    return 0;
}
0