結果
問題 | No.861 ケーキカット |
ユーザー | kotatsugame |
提出日時 | 2020-03-05 18:57:14 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,105 bytes |
コンパイル時間 | 670 ms |
コンパイル使用メモリ | 78,100 KB |
実行使用メモリ | 93,312 KB |
最終ジャッジ日時 | 2024-04-22 03:12:30 |
合計ジャッジ時間 | 5,418 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 184 ms
68,736 KB |
testcase_01 | AC | 151 ms
69,248 KB |
testcase_02 | AC | 131 ms
64,000 KB |
testcase_03 | AC | 389 ms
93,312 KB |
testcase_04 | AC | 131 ms
64,700 KB |
testcase_05 | AC | 174 ms
71,040 KB |
testcase_06 | AC | 168 ms
34,176 KB |
testcase_07 | AC | 94 ms
48,640 KB |
testcase_08 | AC | 106 ms
39,936 KB |
testcase_09 | AC | 109 ms
60,160 KB |
testcase_10 | AC | 100 ms
55,808 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 7 | main() | ^~~~
ソースコード
#include<iostream> #include<queue> #include<algorithm> using namespace std; long C[25]; long sum[1<<25]; main() { long all=0; for(int i=0;i<25;i++) { cin>>C[i]; all+=C[i]; } queue<int>P; long ans=all; for(int i=0;i<25;i++) { sum[1<<i]=C[i]; if(C[i]*2<=all) { P.push(1<<i); } else { ans=min(ans,C[i]*2-all); } } while(!P.empty()) { int u=P.front();P.pop(); ans=min(ans,all-sum[u]*2); for(int i=0;i<25;i++) { if(!(u>>i&1))continue; if(i>=5&&!(u>>i-5&1)) { int v=u|1<<i-5; long t=sum[u]+C[i-5]; if(!sum[v]&&2*t<=all) { sum[v]=t; P.push(v); } } if(i<20&&!(u>>i+5&1)) { int v=u|1<<i+5; long t=sum[u]+C[i+5]; if(!sum[v]&&2*t<=all) { sum[v]=t; P.push(v); } } if(i%5>0&&!(u>>i-1&1)) { int v=u|1<<i-1; long t=sum[u]+C[i-1]; if(!sum[v]&&2*t<=all) { sum[v]=t; P.push(v); } } if(i%5<4&&!(u>>i+1&1)) { int v=u|1<<i+1; long t=sum[u]+C[i+1]; if(!sum[v]&&2*t<=all) { sum[v]=t; P.push(v); } } } } cout<<ans<<endl; }