結果
問題 | No.1633 Sorting Integers (Multiple of 2^K) |
ユーザー |
|
提出日時 | 2021-07-30 22:13:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 397 bytes |
コンパイル時間 | 570 ms |
コンパイル使用メモリ | 63,616 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-16 00:34:18 |
合計ジャッジ時間 | 2,475 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
コンパイルメッセージ
main.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 22 | main() | ^~~~
ソースコード
#include<iostream>using namespace std;int ans=0;int N,K;int C[10];void dfs(int id,long now,long p){if(id==N){while(now>0&&now%2==0)now/=2,id++;if(ans<id)ans=id;return;}if(ans<id)ans=id;for(int i=1;i<=9;i++)if(C[i]&&(now+p*i)%2==0){C[i]--;dfs(id+1,(now+p*i)/2,p*5);C[i]++;}}main(){cin>>N;for(int i=1;i<=9;i++)cin>>C[i];dfs(0,0,1);cout<<ans<<endl;}