結果

問題 No.1014 competitive fighting
ユーザー otamay6
提出日時 2020-02-19 17:21:55
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,162 bytes
コンパイル時間 2,278 ms
コンパイル使用メモリ 178,008 KB
実行使用メモリ 928,660 KB
最終ジャッジ日時 2024-12-14 16:14:19
合計ジャッジ時間 118,054 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 TLE * 17 MLE * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;cin>>N;
    vector<ll> A(N),B(N),C(N);
    REP(i,N) cin>>A[i]>>B[i]>>C[i];
    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;
        }
    }
    REP(i,N){
        if(negative[i]) cout<<"BAN"<<endl;
        else cout<<B[i]-dist[i]<<endl;
    }
}
0