結果

問題 No.1950 片道きゃっちぼーる
ユーザー renren_utsrenren_uts
提出日時 2022-06-16 16:44:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,176 bytes
コンパイル時間 1,282 ms
コンパイル使用メモリ 116,812 KB
実行使用メモリ 53,204 KB
最終ジャッジ日時 2024-04-16 04:47:18
合計ジャッジ時間 17,169 ms
ジャッジサーバーID
(参考情報)
judge5 / 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 589 ms
47,120 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 523 ms
34,576 KB
testcase_07 AC 692 ms
53,204 KB
testcase_08 AC 926 ms
53,196 KB
testcase_09 WA -
testcase_10 AC 646 ms
47,076 KB
testcase_11 AC 652 ms
47,080 KB
testcase_12 AC 629 ms
46,952 KB
testcase_13 AC 567 ms
39,588 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 548 ms
34,708 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 646 ms
50,328 KB
testcase_19 WA -
testcase_20 AC 635 ms
40,824 KB
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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[i].push_back(j-1);
    }
    j = mp[x[i]-a[i]];
    if(j != 0){
      v[i].push_back(j-1);
    }
  }
  priority_queue<tuple<ll,ll>> q;
  rep(i,n){
    q.push(make_tuple((x[i]+a[i]),i));
  }
  vector<ll> ans(n,0);
  rep(i,n){
    ll j = get<1>(q.top());
    q.pop();
    ans[j] = x[j]+a[j];
    for(ll k:v[j]){
      ans[j] = max(ans[j],ans[k]);
    }
  }
  rep(i,n)cout << ans[i]-x[i] << endl;
  
  return 0;
}
0