結果

問題 No.555 世界史のレポート
ユーザー iwashi31iwashi31
提出日時 2017-08-12 00:14:46
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 1,448 bytes
コンパイル時間 798 ms
コンパイル使用メモリ 97,984 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-12 22:29:11
合計ジャッジ時間 1,464 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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