結果
| 問題 |
No.1014 competitive fighting
|
| コンテスト | |
| ユーザー |
otamay6
|
| 提出日時 | 2020-02-19 16:36:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,514 bytes |
| コンパイル時間 | 2,776 ms |
| コンパイル使用メモリ | 184,652 KB |
| 実行使用メモリ | 1,299,284 KB |
| 最終ジャッジ日時 | 2024-12-14 16:12:13 |
| 合計ジャッジ時間 | 129,465 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 2 TLE * 33 MLE * 16 |
ソースコード
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;
int main(){
int N,Q;cin>>N>>Q;
vector<ll> A(N),B(N),C(N);
REP(i,N) cin>>A[i]>>B[i]>>C[i];
vector<int> ord(N);
iota(All(ord),0);
sort(All(ord),[&](int x,int y){return A[x]<A[y];});
vector<vector<pair<ll,int>>> graph(N);
REP(i,N) REP(j,N) if(i!=j){
if(A[i]<=B[j]-C[j]) graph[i].push_back(make_pair(-B[i],j));
}
vector<ll> dist(N,0);
REP(i,N-1) REP(j,N){
REP(k,graph[j].size()){
int TO=graph[j][k].second,COST=graph[j][k].first;
dist[TO]=min(dist[TO],dist[j]+COST);
}
}
vector<bool> negative(N,false);
REP(i,N) REP(j,N){
REP(k,graph[j].size()){
int TO=graph[j][k].second,COST=graph[j][k].first;
if(dist[TO]>dist[j]+COST){
dist[TO]=dist[j]+COST;
negative[TO]=true;
}
if(negative[j]) negative[TO]=true;
}
}
const ll INF=LLONG_MAX;
vector<ll> S(N+1);
REP(i,N){
if(negative[ord[i]]) S[i+1]=INF;
else S[i+1]=max(S[i],B[ord[i]]-dist[ord[i]]);
}
sort(All(A));
REP(q,Q){
int D;cin>>D;
int k = upper_bound(All(A),D)-A.begin();
if(S[k]==INF) cout<<"BAN"<<endl;
else cout<<S[k]<<endl;
}
}
otamay6