結果
| 問題 |
No.1676 Coin Trade (Single)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-10 21:37:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 114 ms / 2,000 ms |
| コード長 | 604 bytes |
| コンパイル時間 | 702 ms |
| コンパイル使用メモリ | 73,316 KB |
| 実行使用メモリ | 10,412 KB |
| 最終ジャッジ日時 | 2024-06-11 22:48:31 |
| 合計ジャッジ時間 | 3,461 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
9 | main()
| ^~~~
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N,K;
int A[1<<17];
vector<pair<int,int> >G[1<<17];
long dist[1<<17];
main()
{
cin>>N>>K;
for(int i=1;i<=N;i++)
{
int M;
cin>>A[i]>>M;
G[0].push_back(make_pair(i,0));
for(int j=0;j<M;j++)
{
int u;cin>>u;
G[u].push_back(make_pair(i,A[i]-A[u]));
}
}
long ans=0;
for(int i=0;i<=N;i++)
{
ans=max(ans,dist[i]);
if(i<N)dist[i+1]=max(dist[i+1],dist[i]);
for(pair<int,int>e:G[i])
{
int v=e.first;
if(dist[v]<dist[i]+e.second)
{
dist[v]=dist[i]+e.second;
}
}
}
cout<<ans<<endl;
}