# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1087837 |
2024-09-13T10:02:30 Z |
akim9905 |
None (JOI14_ho_t4) |
C++17 |
|
117 ms |
26572 KB |
#include <bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define fio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) (x).begin(), (x).end()
#define allr(x) x.rbegin(), x.rend()
#define cmprs(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define endl "\n"
#define sp " "
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define rz resize
#define sz(a) (int)(a.size())
#define clr(a) a.clear()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef tuple<int, int, int> tpi;
typedef tuple<ll, ll, ll> tpl;
typedef pair<double, ll> pdl;
typedef pair<double, int> pdi;
const int dx[] = {1,-1,0,0,1,1,-1,-1};
const int dy[] = {0,0,1,-1,1,-1,1,-1};
const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MAX = 101010; // PLZ CHK!
int N,M;
ll X,H[MAX],D[MAX];
vector<pll> G[MAX];
int main() {
fio();
cin>>N>>M>>X;
for (int i=1; i<=N; i++) cin>>H[i];
for (int i=0; i<M; i++) {
int u,v,w; cin>>u>>v>>w;
G[u].pb({v,w}), G[v].pb({u,w});
}
fill(D,D+N+10,LINF);
priority_queue<pll,vector<pll>,greater<pll>> pq;
D[1]=0;
pq.push({D[1],1});
while (!pq.empty()) {
auto [dst,cur]=pq.top(); pq.pop();
if (dst!=D[cur]) continue;
for (auto [nxt,cst]:G[cur]) {
if (D[nxt]>D[cur]+cst*2 && H[cur]>=cst) {
D[nxt]=D[cur]+cst*2;
pq.push({D[nxt],nxt});
}
}
}
cout<<(D[N]==LINF?-1:D[N]+H[N]);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2908 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2908 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
117 ms |
26572 KB |
Output is correct |
2 |
Correct |
87 ms |
25476 KB |
Output is correct |
3 |
Correct |
63 ms |
14260 KB |
Output is correct |
4 |
Correct |
100 ms |
25284 KB |
Output is correct |
5 |
Correct |
75 ms |
24224 KB |
Output is correct |
6 |
Correct |
5 ms |
3928 KB |
Output is correct |
7 |
Correct |
92 ms |
24996 KB |
Output is correct |
8 |
Correct |
99 ms |
22308 KB |
Output is correct |
9 |
Correct |
89 ms |
25264 KB |
Output is correct |
10 |
Correct |
63 ms |
18768 KB |
Output is correct |
11 |
Correct |
11 ms |
4756 KB |
Output is correct |
12 |
Correct |
56 ms |
17656 KB |
Output is correct |
13 |
Correct |
26 ms |
13144 KB |
Output is correct |
14 |
Correct |
91 ms |
24648 KB |
Output is correct |
15 |
Correct |
4 ms |
3416 KB |
Output is correct |
16 |
Correct |
77 ms |
24064 KB |
Output is correct |
17 |
Correct |
15 ms |
4776 KB |
Output is correct |
18 |
Correct |
14 ms |
5212 KB |
Output is correct |
19 |
Correct |
42 ms |
12000 KB |
Output is correct |
20 |
Correct |
12 ms |
5468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2908 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2908 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |