結果

問題 No.1950 片道きゃっちぼーる
ユーザー 蜜蜂蜜蜂
提出日時 2022-05-06 01:05:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,448 bytes
コンパイル時間 4,155 ms
コンパイル使用メモリ 236,852 KB
実行使用メモリ 44,644 KB
最終ジャッジ日時 2023-09-18 11:26:40
合計ジャッジ時間 16,663 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 513 ms
31,920 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 497 ms
19,992 KB
testcase_07 AC 555 ms
44,644 KB
testcase_08 AC 638 ms
44,608 KB
testcase_09 WA -
testcase_10 AC 513 ms
31,968 KB
testcase_11 AC 554 ms
32,024 KB
testcase_12 AC 495 ms
31,860 KB
testcase_13 AC 496 ms
24,564 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 497 ms
19,992 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 531 ms
38,196 KB
testcase_19 WA -
testcase_20 AC 506 ms
32,116 KB
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:60:10: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   60 |     auto [sm,id]=que.top();
      |          ^

ソースコード

diff #

//g++ 2.cpp -std=c++14 -O2 -I .
#include <bits/stdc++.h>
using namespace std;

#include <atcoder/all>
using namespace atcoder;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vst = vector<string>;
using vvst = vector<vst>;

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define pq_big(T) priority_queue<T,vector<T>,less<T>>
#define pq_small(T) priority_queue<T,vector<T>,greater<T>>
#define all(a) a.begin(),a.end()
#define rep(i,start,end) for(ll i=start;i<(ll)(end);i++)
#define per(i,start,end) for(ll i=start;i>=(ll)(end);i--)
#define uniq(a) sort(all(a));a.erase(unique(all(a)),a.end())

using P = pair<int,int>;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin>>n;

  vi x(n),a(n);
  rep(i,0,n)cin>>x[i];
  rep(i,0,n)cin>>a[i];

  map<ll,int> m;
  rep(i,0,n){
    m[x[i]]=i+1;
  }

  vi opt(n);
  rep(i,0,n){
    opt[i]=x[i]+a[i];
  }

  pq_big(P) que;
  rep(i,0,n){
    que.push({x[i]+a[i],i});
  }

  while(!que.empty()){
    auto [sm,id]=que.top();
    que.pop();

    int l=x[id]-a[id],r=x[id]+a[id];

    if(m[l]!=0){
      int nxt=m[l]-1;
      opt[id]=max(opt[id],opt[nxt]);
    }
    if(m[r]!=0){
      int nxt=m[r]-1;
      opt[id]=max(opt[id],opt[nxt]);
    }
  }

  rep(i,0,n){
    cout<<opt[i]-x[i]<<endl;
  }
}
0