結果

問題 No.1676 Coin Trade (Single)
ユーザー kotatsugamekotatsugame
提出日時 2021-09-10 21:37:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 604 bytes
コンパイル時間 1,135 ms
コンパイル使用メモリ 73,868 KB
実行使用メモリ 10,208 KB
最終ジャッジ日時 2023-09-02 16:15:46
合計ジャッジ時間 3,979 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,380 KB
testcase_01 AC 3 ms
6,484 KB
testcase_02 AC 3 ms
6,448 KB
testcase_03 AC 79 ms
9,004 KB
testcase_04 AC 72 ms
9,020 KB
testcase_05 AC 66 ms
8,640 KB
testcase_06 AC 68 ms
8,600 KB
testcase_07 AC 59 ms
8,296 KB
testcase_08 AC 37 ms
7,748 KB
testcase_09 AC 57 ms
8,356 KB
testcase_10 AC 58 ms
8,432 KB
testcase_11 AC 83 ms
9,052 KB
testcase_12 AC 46 ms
8,168 KB
testcase_13 AC 3 ms
6,416 KB
testcase_14 AC 3 ms
6,632 KB
testcase_15 AC 3 ms
6,692 KB
testcase_16 AC 3 ms
6,488 KB
testcase_17 AC 3 ms
6,496 KB
testcase_18 AC 3 ms
6,384 KB
testcase_19 AC 3 ms
6,412 KB
testcase_20 AC 3 ms
6,392 KB
testcase_21 AC 3 ms
6,484 KB
testcase_22 AC 3 ms
6,416 KB
testcase_23 AC 3 ms
6,400 KB
testcase_24 AC 3 ms
6,484 KB
testcase_25 AC 3 ms
6,420 KB
testcase_26 AC 3 ms
6,496 KB
testcase_27 AC 3 ms
6,412 KB
testcase_28 AC 3 ms
6,476 KB
testcase_29 AC 3 ms
6,420 KB
testcase_30 AC 3 ms
6,492 KB
testcase_31 AC 4 ms
6,548 KB
testcase_32 AC 3 ms
6,388 KB
testcase_33 AC 100 ms
10,208 KB
testcase_34 AC 101 ms
10,200 KB
testcase_35 AC 102 ms
10,068 KB
testcase_36 AC 100 ms
10,160 KB
testcase_37 AC 100 ms
10,148 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:9:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    9 | main()
      | ^~~~

ソースコード

diff #

#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;
}
0