結果

問題 No.1037 exhausted
コンテスト
ユーザー TonalidadeHidrica
提出日時 2020-04-24 22:25:05
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,185 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,216 ms
コンパイル使用メモリ 227,824 KB
実行使用メモリ 439,040 KB
最終ジャッジ日時 2026-06-09 17:38:55
合計ジャッジ時間 6,960 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

using pll = pair<ll, ll>;
map<ll, vector<pll>> g;
pque<pll> que;
set<ll> st;

int main(){
	int n; ll u, l; scanf("%d%lld%lld", &n, &u, &l);
	REP(i, n){
		ll x, v, w; scanf("%lld%lld%lld", &x, &v, &w);
		REP(j, u){
			g[x + j].EB(x + min(j+v, u), w);
		}
	}
	que.emplace(0, u);
	while(que.size()){
		ll w = que.top().first, x = que.top().second; que.pop();
		if(x >= l){
			printf("%lld\n", w);
			return 0;
		}
		if(st.find(x) != st.end()) continue;
		st.emplace(x);
		for(auto &p : g[x]){
			que.emplace(w + p.second, p.first);
		}
	}
	printf("-1\n");
}
0