結果

問題 No.1 道のショートカット
ユーザー tashikanitashikani
提出日時 2015-05-18 22:14:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,580 bytes
コンパイル時間 2,243 ms
コンパイル使用メモリ 91,392 KB
実行使用メモリ 48,532 KB
最終ジャッジ日時 2023-09-22 12:15:27
合計ジャッジ時間 8,643 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 OLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define INT_MAX 2000000000

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


typedef struct state{
	int pos;
	int money;
	int time;
}state;

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

	int N, C, V;
	cin >> N >> C >> V;

	int S[1500], T[1500], Y[1500], M[1500];
	int Yen[51][51], Minute[51][51];

	REP(i, 50) REP(j, 50){
		Yen[i + 1][j + 1] = -1;
		Minute[i + 1][j + 1] = -1;
	}
	cout << V << endl;
	REP(i, V) {
		cin >> S[i];
		cout << i;
	}
	REP(i, V) cin >> T[i];
	REP(i, V) cin >> Y[i];
	REP(i, V) cin >> M[i];

	REP(i, V){
		Yen[S[i]][T[i]] = Y[i];
		Minute[S[i]][T[i]] = M[i];
	}

	queue<state> que;

		state start;
		start.pos = 1;
		start.money = 0;
		start.time = 0;
		que.push(start);
	int retMinute = INT_MAX;

	while(que.empty() == false){
		state cur, tmp;
		cur = que.front();
		que.pop();
		FOR(i, cur.pos, N){
			if(Yen[cur.pos][i + 1] != -1){
				tmp.pos = i + 1;
				tmp.money = cur.money + Yen[cur.pos][i + 1];
				tmp.time = cur.time + Minute[cur.pos][i + 1];
				if(i + 1 == N && tmp.money <= C && tmp.time < retMinute){
					retMinute = tmp.time;
				}
				que.push(tmp);
				cout << cur.pos << " " << i << " " << tmp.time << endl;
			}
		}
	}
	if(retMinute == INT_MAX){
		retMinute = -1;
	}
	cout << retMinute << endl;

	return 0;
}
0