結果

問題 No.2146 2 Pows
ユーザー kotatsugamekotatsugame
提出日時 2022-12-02 23:03:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 124 ms / 3,000 ms
コード長 689 bytes
コンパイル時間 799 ms
コンパイル使用メモリ 76,828 KB
実行使用メモリ 10,884 KB
最終ジャッジ日時 2024-04-18 08:20:50
合計ジャッジ時間 5,609 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 79 ms
7,560 KB
testcase_06 AC 100 ms
8,576 KB
testcase_07 AC 74 ms
10,884 KB
testcase_08 AC 103 ms
10,756 KB
testcase_09 AC 124 ms
10,628 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 6 ms
5,376 KB
testcase_16 AC 54 ms
6,732 KB
testcase_17 AC 64 ms
6,776 KB
testcase_18 AC 27 ms
5,376 KB
testcase_19 AC 87 ms
8,088 KB
testcase_20 AC 92 ms
8,104 KB
testcase_21 AC 35 ms
6,624 KB
testcase_22 AC 92 ms
10,400 KB
testcase_23 AC 65 ms
8,048 KB
testcase_24 AC 66 ms
6,676 KB
testcase_25 AC 76 ms
6,900 KB
testcase_26 AC 102 ms
8,492 KB
testcase_27 AC 78 ms
7,116 KB
testcase_28 AC 81 ms
6,672 KB
testcase_29 AC 23 ms
5,376 KB
testcase_30 AC 60 ms
6,376 KB
testcase_31 AC 70 ms
7,416 KB
testcase_32 AC 18 ms
5,376 KB
testcase_33 AC 62 ms
6,776 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<queue>
using namespace std;
int N,A,B,C;
long dp[2<<17][2];
main()
{
	cin>>N>>A>>B>>C;
	for(int i=0;i<N;i++)dp[i][0]=dp[i][1]=9e18;
	dp[1][1]=A+B;
	priority_queue<pair<long,pair<int,int> > >Q;
	Q.push(make_pair(-A-B,make_pair(1,1)));
	while(!Q.empty())
	{
		long c=-Q.top().first;
		int i=Q.top().second.first,j=Q.top().second.second;
		Q.pop();
		if(dp[i][j]<c)continue;
		if(dp[i*2%N][0]>c+C)
		{
			dp[i*2%N][0]=c+C;
			Q.push(make_pair(-c-C,make_pair(i*2%N,0)));
		}
		long nc=c+A+(j==0?B:0);
		if(dp[(i+1)%N][1]>nc)
		{
			dp[(i+1)%N][1]=nc;
			Q.push(make_pair(-nc,make_pair((i+1)%N,1)));
		}
	}
	for(int i=0;i<N;i++)cout<<min(dp[i][0],dp[i][1])<<"\n";
}
0