結果
問題 | No.1950 片道きゃっちぼーる |
ユーザー | renren_uts |
提出日時 | 2022-06-16 22:02:08 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,020 ms / 3,000 ms |
コード長 | 1,385 bytes |
コンパイル時間 | 1,346 ms |
コンパイル使用メモリ | 117,352 KB |
実行使用メモリ | 53,328 KB |
最終ジャッジ日時 | 2024-04-16 11:32:08 |
合計ジャッジ時間 | 17,332 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 590 ms
46,948 KB |
testcase_04 | AC | 596 ms
46,948 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 528 ms
34,444 KB |
testcase_07 | AC | 684 ms
53,328 KB |
testcase_08 | AC | 948 ms
53,188 KB |
testcase_09 | AC | 613 ms
46,588 KB |
testcase_10 | AC | 616 ms
43,036 KB |
testcase_11 | AC | 636 ms
43,800 KB |
testcase_12 | AC | 603 ms
43,796 KB |
testcase_13 | AC | 569 ms
38,968 KB |
testcase_14 | AC | 560 ms
36,024 KB |
testcase_15 | AC | 986 ms
46,952 KB |
testcase_16 | AC | 550 ms
34,504 KB |
testcase_17 | AC | 1 ms
5,376 KB |
testcase_18 | AC | 645 ms
50,200 KB |
testcase_19 | AC | 1,020 ms
46,944 KB |
testcase_20 | AC | 638 ms
40,700 KB |
testcase_21 | AC | 570 ms
37,620 KB |
testcase_22 | AC | 570 ms
36,952 KB |
ソースコード
#include <iostream> #include <stdio.h> #include <cmath> #include <vector> #include <tuple> #include <bitset> #include <map> #include <queue> #include <time.h> #include <utility> #include <numeric> #include <deque> #include <cassert> #include <sstream> #include <cctype> #include <unordered_map> #include <algorithm> #include <chrono> #define ll long long #include <time.h> #define mod % 998244353 #define rep(i,n) for(long long i = 0;i < n;i ++) ll MAX = 5'000'000'000'000'000'000LL; using namespace std; int main(){ ll n; cin >> n; vector<ll> x(n); vector<ll> a(n); rep(i,n)cin >> x[i]; rep(i,n)cin >> a[i]; map<ll,ll> mp; rep(i,n){ mp[x[i]] = i+1; } vector<vector<ll>> v(n); rep(i,n){ ll j = mp[x[i]+a[i]]; if(j != 0){ v[j-1].push_back(i); } j = 0; j = mp[x[i]-a[i]]; if(j != 0){ v[j-1].push_back(i); } } priority_queue<tuple<ll,ll>> q; rep(i,n){ q.push(make_tuple((x[i]+a[i]),i)); } vector<ll> ans(n,-100); rep(i,n){ ll j = get<1>(q.top()); q.pop(); if(ans[j]>=x[j]+a[j])continue; ans[j] = x[j]+a[j]; vector<ll> nex = v[j]; while(not nex.empty()){ ll k = nex.back(); nex.pop_back(); if(ans[k]>=ans[j])continue; ans[k] = ans[j]; for(ll l:v[k]){ nex.push_back(l); } } } rep(i,n)cout << ans[i]-x[i] << endl; return 0; }