結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
newlife171128
|
| 提出日時 | 2017-12-22 22:12:18 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 657 bytes |
| コンパイル時間 | 1,677 ms |
| コンパイル使用メモリ | 65,288 KB |
| 実行使用メモリ | 17,224 KB |
| 最終ジャッジ日時 | 2024-12-17 23:49:32 |
| 合計ジャッジ時間 | 176,805 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 2 TLE * 28 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;
int main() {
int n =0;
cin>>n;
int nums[n] ;
int tmp=0;
for(int i=0; i<n;i++){
cin>>tmp;
nums[i] =tmp;
}
long long all_pattern = pow(2,n);
bool judge =false;
int ans=-1;
for(int i=0; i<all_pattern; i++){
tmp =0;
judge =false;
for(int k=0; k<n; k++){
/* cout<<"i:"<<i<<endl;*/
if((i>>k)%2 ==1){
if(judge){
break;
}
judge = true;
tmp += nums[k];
}else {
judge =false;
}
}
/*cout<<"tmp:"<<tmp<<endl;*/
ans = max(ans,tmp);
}
cout<<ans<<endl;
return 0;
}
newlife171128