diff --git a/S2OJ/1604/1604.cpp b/S2OJ/1604/1604.cpp new file mode 100644 index 00000000..0ef04c0f --- /dev/null +++ b/S2OJ/1604/1604.cpp @@ -0,0 +1,106 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 1e5 + 5; + +int n, m; +long long s, alt[N]; +std::vector alts; +std::vector> g[N]; +std::array vis; +std::array dist; + +void dijkstra(long long limit) { + std::fill(vis.begin(), vis.end(), false); + std::fill(dist.begin(), dist.end(), std::numeric_limits::max() / 3); + + std::priority_queue, std::vector>, std::greater>> q; + + q.emplace(0, 1); + dist[1] = 0; + + while (!q.empty()) { + int u = q.top().second; + q.pop(); + + if (vis[u]) continue; + vis[u] = true; + + for (auto e : g[u]) { + int v = e.first; + long long w = e.second; + + if (dist[v] > dist[u] + w && alt[v] - alt[u] <= limit) { + dist[v] = dist[u] + w; + q.emplace(dist[v], v); + } + } + } +} + +bool check(int x) { + dijkstra(alts[x]); + + return dist[n] <= s; +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n >> m >> s; + + for (int i = 1; i <= n; i++) { + cin >> alt[i]; + } + + for (int i = 1; i <= m; i++) { + int u, v; + long long w; + + cin >> u >> v >> w; + + g[u].emplace_back(v, w); + alts.emplace_back(alt[v] - alt[u]); + + g[v].emplace_back(u, w); + alts.emplace_back(alt[u] - alt[v]); + } + + std::sort(alts.begin(), alts.end()); + alts.erase(std::unique(alts.begin(), alts.end()), alts.end()); + + int l = 0, + r = alts.size() - 1, + res = alts.size(); + + while (l <= r) { + int mid = l + r >> 1; + + if (check(mid)) { + r = mid - 1; + res = mid; + } else { + l = mid + 1; + } + } + + if (res == alts.size()) { + cout << "NO" << endl; + } else { + cout << alts[res] << endl; + } + + return 0; +} diff --git a/S2OJ/1604/data/bicycle1.in b/S2OJ/1604/data/bicycle1.in new file mode 100644 index 00000000..15937ad7 --- /dev/null +++ b/S2OJ/1604/data/bicycle1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b200b2ee6cdf98bd659db6671cda712f020ca9c55061b7d7de24c44833356962 +size 17 diff --git a/S2OJ/1604/data/bicycle1.out b/S2OJ/1604/data/bicycle1.out new file mode 100644 index 00000000..2acbdf45 --- /dev/null +++ b/S2OJ/1604/data/bicycle1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0b2f06dddfa807ee574a78468d3a05904873b97f44377eb93481e091c257b800 +size 3 diff --git a/S2OJ/1604/data/bicycle10.in b/S2OJ/1604/data/bicycle10.in new file mode 100644 index 00000000..d32eedd8 --- /dev/null +++ b/S2OJ/1604/data/bicycle10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f80095160ce95d877400341ef1a72d593c8b8c05073a1fb9dd263df5d9a55037 +size 2148842 diff --git a/S2OJ/1604/data/bicycle10.out b/S2OJ/1604/data/bicycle10.out new file mode 100644 index 00000000..81d868ef --- /dev/null +++ b/S2OJ/1604/data/bicycle10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cfe72034a9f298fb79a6c1f2302673bb449c826d446b3efafdde95e6c48dc3ca +size 3 diff --git a/S2OJ/1604/data/bicycle11.in b/S2OJ/1604/data/bicycle11.in new file mode 100644 index 00000000..66011e69 --- /dev/null +++ b/S2OJ/1604/data/bicycle11.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:505f0d0be6f513450f0f821e8b9057eb29b376a243572b5ede2a0722dd6f0285 +size 2172623 diff --git a/S2OJ/1604/data/bicycle11.out b/S2OJ/1604/data/bicycle11.out new file mode 100644 index 00000000..38118f32 --- /dev/null +++ b/S2OJ/1604/data/bicycle11.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:53c234e5e8472b6ac51c1ae1cab3fe06fad053beb8ebfd8977b010655bfdd3c3 +size 2 diff --git a/S2OJ/1604/data/bicycle12.in b/S2OJ/1604/data/bicycle12.in new file mode 100644 index 00000000..c3c4b0ab --- /dev/null +++ b/S2OJ/1604/data/bicycle12.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b74427dbc5cca74b8c063895de8889f0ab21adfce3adb6a02b9cb2adba381275 +size 2502198 diff --git a/S2OJ/1604/data/bicycle12.out b/S2OJ/1604/data/bicycle12.out new file mode 100644 index 00000000..f98f67e5 --- /dev/null +++ b/S2OJ/1604/data/bicycle12.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:65ab1ecb7a4196efecc8e9fc831acc829b855faf4239b8a3446d02701e42984b +size 8 diff --git a/S2OJ/1604/data/bicycle13.in b/S2OJ/1604/data/bicycle13.in new file mode 100644 index 00000000..e0e3f978 --- /dev/null +++ b/S2OJ/1604/data/bicycle13.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7df7fff798c2904b4c8a986379d4298b3df46f6b7d03be889efb0b8bf3cd7b32 +size 2584704 diff --git a/S2OJ/1604/data/bicycle13.out b/S2OJ/1604/data/bicycle13.out new file mode 100644 index 00000000..1f80b648 --- /dev/null +++ b/S2OJ/1604/data/bicycle13.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c5a74a8cd3272fcfe9eb901467c88232a4b4a30ebffdc26f1f937b11e3d7c3b3 +size 8 diff --git a/S2OJ/1604/data/bicycle14.in b/S2OJ/1604/data/bicycle14.in new file mode 100644 index 00000000..ea3b1e23 --- /dev/null +++ b/S2OJ/1604/data/bicycle14.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3cf411239d64ad2c30ff92c4e32476132421d2a60f8788e70b6a6ed4a7b84614 +size 2666018 diff --git a/S2OJ/1604/data/bicycle14.out b/S2OJ/1604/data/bicycle14.out new file mode 100644 index 00000000..66d68f1e --- /dev/null +++ b/S2OJ/1604/data/bicycle14.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c5378d51d8d21fc126f077100fc23ee7ae5243c46f1476679f30fbeac1134c39 +size 8 diff --git a/S2OJ/1604/data/bicycle15.in b/S2OJ/1604/data/bicycle15.in new file mode 100644 index 00000000..cdd64676 --- /dev/null +++ b/S2OJ/1604/data/bicycle15.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2039187bda7bf0b33629422ec79a7a55bb0bee6240cb90e06ba78696da5a3b1c +size 2746442 diff --git a/S2OJ/1604/data/bicycle15.out b/S2OJ/1604/data/bicycle15.out new file mode 100644 index 00000000..1d4c0b9e --- /dev/null +++ b/S2OJ/1604/data/bicycle15.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6e240df54724b8e39e8f9d3fce45570fdc01e0276662c897124d5700178f1503 +size 8 diff --git a/S2OJ/1604/data/bicycle16.in b/S2OJ/1604/data/bicycle16.in new file mode 100644 index 00000000..e69215a8 --- /dev/null +++ b/S2OJ/1604/data/bicycle16.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9d414afb462573094cb25fc96ba86e2b95eb5a873cff04db8f3b76473dbfe540 +size 2502129 diff --git a/S2OJ/1604/data/bicycle16.out b/S2OJ/1604/data/bicycle16.out new file mode 100644 index 00000000..81d868ef --- /dev/null +++ b/S2OJ/1604/data/bicycle16.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cfe72034a9f298fb79a6c1f2302673bb449c826d446b3efafdde95e6c48dc3ca +size 3 diff --git a/S2OJ/1604/data/bicycle17.in b/S2OJ/1604/data/bicycle17.in new file mode 100644 index 00000000..fa7c6cc6 --- /dev/null +++ b/S2OJ/1604/data/bicycle17.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e606cde77a9e715c9f0183b7e5a3c44c7ebf4324b2e1285694e8941828e7fcc +size 2584914 diff --git a/S2OJ/1604/data/bicycle17.out b/S2OJ/1604/data/bicycle17.out new file mode 100644 index 00000000..81d868ef --- /dev/null +++ b/S2OJ/1604/data/bicycle17.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cfe72034a9f298fb79a6c1f2302673bb449c826d446b3efafdde95e6c48dc3ca +size 3 diff --git a/S2OJ/1604/data/bicycle18.in b/S2OJ/1604/data/bicycle18.in new file mode 100644 index 00000000..158cde7a --- /dev/null +++ b/S2OJ/1604/data/bicycle18.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4f7ffba4095e03f5decc0742006863b3f03e1f887366c8f6209dfa09836c0d17 +size 2418003 diff --git a/S2OJ/1604/data/bicycle18.out b/S2OJ/1604/data/bicycle18.out new file mode 100644 index 00000000..fdf58285 --- /dev/null +++ b/S2OJ/1604/data/bicycle18.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:81f713571eb1d44e55e4945ff127cdc3ed864ca4b2690a98e9804dedfdbebd2b +size 8 diff --git a/S2OJ/1604/data/bicycle19.in b/S2OJ/1604/data/bicycle19.in new file mode 100644 index 00000000..0e7f9b38 --- /dev/null +++ b/S2OJ/1604/data/bicycle19.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f598fca5aca35c3bbb9d70ce29696d07189d17cb212d8a5aa066d32b8b653686 +size 2418042 diff --git a/S2OJ/1604/data/bicycle19.out b/S2OJ/1604/data/bicycle19.out new file mode 100644 index 00000000..9418d828 --- /dev/null +++ b/S2OJ/1604/data/bicycle19.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a7740fac236033107e138e48a0c4933d3b56da779aebb2025f4c067d80447b8 +size 8 diff --git a/S2OJ/1604/data/bicycle2.in b/S2OJ/1604/data/bicycle2.in new file mode 100644 index 00000000..b2aeb5a1 --- /dev/null +++ b/S2OJ/1604/data/bicycle2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ce6b06a36fafa7e45c43df2765bcd37b209c6ab03b0f97157f9ff44267512311 +size 1154 diff --git a/S2OJ/1604/data/bicycle2.out b/S2OJ/1604/data/bicycle2.out new file mode 100644 index 00000000..fe84fbbb --- /dev/null +++ b/S2OJ/1604/data/bicycle2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:36d28c461c3b0cc3241cd7b840dbb9fae464838164f0d9cb9e80a20224de6321 +size 4 diff --git a/S2OJ/1604/data/bicycle20.in b/S2OJ/1604/data/bicycle20.in new file mode 100644 index 00000000..4435da73 --- /dev/null +++ b/S2OJ/1604/data/bicycle20.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c690d978b63dc4d978e3ce726edd9776279552b3e0e3acfe534f06b39594065f +size 18 diff --git a/S2OJ/1604/data/bicycle20.out b/S2OJ/1604/data/bicycle20.out new file mode 100644 index 00000000..4a45747d --- /dev/null +++ b/S2OJ/1604/data/bicycle20.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0f90e0b3538d04df294950dcec75952d7e07f1bb044e73e795c410d677b3c268 +size 3 diff --git a/S2OJ/1604/data/bicycle3.in b/S2OJ/1604/data/bicycle3.in new file mode 100644 index 00000000..d012f78c --- /dev/null +++ b/S2OJ/1604/data/bicycle3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9ee01b1b220b0333f83b2385864d812134decd616d535e94e99a21a2d6e01878 +size 2380 diff --git a/S2OJ/1604/data/bicycle3.out b/S2OJ/1604/data/bicycle3.out new file mode 100644 index 00000000..d2e5644a --- /dev/null +++ b/S2OJ/1604/data/bicycle3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a97d621ec6b93d9b869e8cdb134516925f2baf2fa1c8186a387f6fc35ffb77ad +size 4 diff --git a/S2OJ/1604/data/bicycle4.in b/S2OJ/1604/data/bicycle4.in new file mode 100644 index 00000000..b50cb57f --- /dev/null +++ b/S2OJ/1604/data/bicycle4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6b1054906bd510102b37cfc5092c21b74fbd6455c0dcd484b4d11a8add3541a2 +size 14115 diff --git a/S2OJ/1604/data/bicycle4.out b/S2OJ/1604/data/bicycle4.out new file mode 100644 index 00000000..81d868ef --- /dev/null +++ b/S2OJ/1604/data/bicycle4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cfe72034a9f298fb79a6c1f2302673bb449c826d446b3efafdde95e6c48dc3ca +size 3 diff --git a/S2OJ/1604/data/bicycle5.in b/S2OJ/1604/data/bicycle5.in new file mode 100644 index 00000000..e67ba291 --- /dev/null +++ b/S2OJ/1604/data/bicycle5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8878e0f251518333c7ae182a54fe7a8b5849431e6bb016d53de9bae23c47ffb7 +size 15171 diff --git a/S2OJ/1604/data/bicycle5.out b/S2OJ/1604/data/bicycle5.out new file mode 100644 index 00000000..81d868ef --- /dev/null +++ b/S2OJ/1604/data/bicycle5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cfe72034a9f298fb79a6c1f2302673bb449c826d446b3efafdde95e6c48dc3ca +size 3 diff --git a/S2OJ/1604/data/bicycle6.in b/S2OJ/1604/data/bicycle6.in new file mode 100644 index 00000000..5c16be38 --- /dev/null +++ b/S2OJ/1604/data/bicycle6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:695133296a3afaa35071501c86be0473c4589f88827c0e5037e89727f0c37e54 +size 2123984 diff --git a/S2OJ/1604/data/bicycle6.out b/S2OJ/1604/data/bicycle6.out new file mode 100644 index 00000000..1afab5f7 --- /dev/null +++ b/S2OJ/1604/data/bicycle6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865 +size 2 diff --git a/S2OJ/1604/data/bicycle7.in b/S2OJ/1604/data/bicycle7.in new file mode 100644 index 00000000..d4ee59d7 --- /dev/null +++ b/S2OJ/1604/data/bicycle7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c10959367a7ff8e0f374d7a504a937248c9e48b9397f6be2842129db560b8273 +size 2149217 diff --git a/S2OJ/1604/data/bicycle7.out b/S2OJ/1604/data/bicycle7.out new file mode 100644 index 00000000..1afab5f7 --- /dev/null +++ b/S2OJ/1604/data/bicycle7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865 +size 2 diff --git a/S2OJ/1604/data/bicycle8.in b/S2OJ/1604/data/bicycle8.in new file mode 100644 index 00000000..e372bb41 --- /dev/null +++ b/S2OJ/1604/data/bicycle8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9d838cfac59c7e5dc0dbfcabe2e8550723de3f5e28b90d005dc3d50666428ed7 +size 2172358 diff --git a/S2OJ/1604/data/bicycle8.out b/S2OJ/1604/data/bicycle8.out new file mode 100644 index 00000000..1afab5f7 --- /dev/null +++ b/S2OJ/1604/data/bicycle8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865 +size 2 diff --git a/S2OJ/1604/data/bicycle9.in b/S2OJ/1604/data/bicycle9.in new file mode 100644 index 00000000..70202533 --- /dev/null +++ b/S2OJ/1604/data/bicycle9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fdd4290ae707fb08fba016c2f9eb348c63bbfc540ac2fac445babc3395bbaf48 +size 2123509 diff --git a/S2OJ/1604/data/bicycle9.out b/S2OJ/1604/data/bicycle9.out new file mode 100644 index 00000000..804fcc90 --- /dev/null +++ b/S2OJ/1604/data/bicycle9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a271f2a916b0b6ee6cecb2426f0b3206ef074578be55d9bc94f6f3fe3ab86aa +size 2 diff --git a/S2OJ/1604/data/ex_bicycle1.in b/S2OJ/1604/data/ex_bicycle1.in new file mode 100644 index 00000000..e295ea2b --- /dev/null +++ b/S2OJ/1604/data/ex_bicycle1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cc7722fe394781adbf6d968231fb2bbfde5c95e72c9b5b9b3d5f90386b3cbac3 +size 59 diff --git a/S2OJ/1604/data/ex_bicycle1.out b/S2OJ/1604/data/ex_bicycle1.out new file mode 100644 index 00000000..38118f32 --- /dev/null +++ b/S2OJ/1604/data/ex_bicycle1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:53c234e5e8472b6ac51c1ae1cab3fe06fad053beb8ebfd8977b010655bfdd3c3 +size 2 diff --git a/S2OJ/1604/data/ex_bicycle2.in b/S2OJ/1604/data/ex_bicycle2.in new file mode 100644 index 00000000..70202533 --- /dev/null +++ b/S2OJ/1604/data/ex_bicycle2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fdd4290ae707fb08fba016c2f9eb348c63bbfc540ac2fac445babc3395bbaf48 +size 2123509 diff --git a/S2OJ/1604/data/ex_bicycle2.out b/S2OJ/1604/data/ex_bicycle2.out new file mode 100644 index 00000000..804fcc90 --- /dev/null +++ b/S2OJ/1604/data/ex_bicycle2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9a271f2a916b0b6ee6cecb2426f0b3206ef074578be55d9bc94f6f3fe3ab86aa +size 2 diff --git a/S2OJ/1604/data/problem.conf b/S2OJ/1604/data/problem.conf new file mode 100644 index 00000000..58f9dd8b --- /dev/null +++ b/S2OJ/1604/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ddc14871bb6c3aebbb34b171077ebb8c5309892ff4da9ca7b34f9cc95c933382 +size 183