結果
| 問題 | No.3653 Space-Time Courier |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2026-08-29 15:44:51 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,406 bytes |
| 記録 | |
| コンパイル時間 | 1,678 ms |
| コンパイル使用メモリ | 77,556 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2026-08-29 15:44:59 |
| 合計ジャッジ時間 | 6,931 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | TLE * 1 -- * 27 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 3653.cc: No.3653 Space-Time Courier - yukicoder
*/
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<utility>
using namespace std;
/* constant */
const int MAX_N = 2500;
const long long LINF = 1LL << 60;
/* typedef */
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using vpii = vector<pii>;
/* global variables */
int ps[MAX_N];
vpii nbrs[MAX_N];
ll ds[MAX_N];
/* subroutines */
void dijkstra(int n, int st, ll ds[]) {
fill(ds, ds + n, LINF);
ds[st] = 0;
priority_queue<pli> q;
q.push({0, st});
while (! q.empty()) {
auto [ud, u] = q.top(); q.pop();
ud = -ud;
if (ds[u] != ud) continue;
for (auto [v, w]: nbrs[u]) {
int vd = ud + w;
if (ds[v] > vd)
ds[v] = vd, q.push({-vd, v});
}
}
}
/* main */
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) scanf("%d", ps + i);
for (int i = 0; i < m; i++) {
int u, v, w;
scanf("%d%d%d", &u, &v, &w);
u--, v--;
nbrs[u].push_back({v, w});
}
ll minsum = LINF;
int minc = 0;
for (int st = 0; st < n; st++) {
dijkstra(n, st, ds);
for (int u = 0; u < n; u++)
if (u != st) {
ll sum = ds[u] + ps[st] + ps[u];
if (minsum > sum) minsum = sum, minc = 1;
else if (minsum == sum) minc++;
}
}
printf("%lld %d\n", minsum, minc);
return 0;
}
tnakao0123