結果
| 問題 |
No.1014 competitive fighting
|
| コンテスト | |
| ユーザー |
otamay6
|
| 提出日時 | 2020-02-19 18:06:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,233 bytes |
| コンパイル時間 | 1,910 ms |
| コンパイル使用メモリ | 181,568 KB |
| 実行使用メモリ | 822,196 KB |
| 最終ジャッジ日時 | 2024-12-14 16:09:10 |
| 合計ジャッジ時間 | 106,854 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 TLE * 19 MLE * 18 |
ソースコード
#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);
vector<int> num(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));
num[j]++;
}
}
queue<int> L,S;
REP(i,N){
if(num[i]==0) S.push(i);
}
while(!S.empty()){
int n=S.front();S.pop();
L.push(n);
REP(j,graph[n].size()){
int v=graph[n][j].second;
num[v]--;
if(num[v]==0) S.push(v);
}
}
vector<ll> dist(N);
vector<bool> negative(N,true);
while(!L.empty()){
int u=L.front();L.pop();
negative[u]=false;
for(auto e:graph[u]){
int v=e.second;
dist[v]=min(dist[v],dist[u]+e.first);
}
}
REP(i,N){
if(negative[i]) cout<<"BAN"<<endl;
else cout<<B[i]-dist[i]<<endl;
}
}
otamay6