結果
問題 | No.1678 Coin Trade (Multiple) |
ユーザー |
|
提出日時 | 2021-09-10 22:05:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 274 ms / 5,000 ms |
コード長 | 388 bytes |
コンパイル時間 | 1,332 ms |
コンパイル使用メモリ | 100,440 KB |
実行使用メモリ | 18,400 KB |
最終ジャッジ日時 | 2024-06-12 00:17:45 |
合計ジャッジ時間 | 7,737 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 56 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main() | ^~~~
ソースコード
#include<iostream> #include<atcoder/mincostflow> using namespace std; int N,K; int A[1<<17]; main() { cin>>N>>K; atcoder::mcf_graph<int,long>P(N+1); const long off=1e9; for(int i=1;i<=N;i++) { int M; P.add_edge(i-1,i,K,off); cin>>A[i]>>M; for(int j=0;j<M;j++) { int u;cin>>u; P.add_edge(u,i,1,A[u]-A[i]+(i-u)*off); } } cout<<off*N*K-P.flow(0,N,K).second<<endl; }