結果
| 問題 | No.37 遊園地のアトラクション | 
| コンテスト | |
| ユーザー |  moti | 
| 提出日時 | 2015-07-16 01:26:52 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                CE
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 842 bytes | 
| コンパイル時間 | 513 ms | 
| コンパイル使用メモリ | 75,012 KB | 
| 最終ジャッジ日時 | 2024-11-14 19:05:53 | 
| 合計ジャッジ時間 | 987 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
            
            
            
            
            ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:15:29: error: ‘chmax’ function uses ‘auto’ type specifier without trailing return type
   15 | template<class T> constexpr auto chmax(T& x, T a) { x = max(x, a); }
      |                             ^~~~
main.cpp:15:29: note: deduced return type only available with ‘-std=c++14’ or ‘-std=gnu++14’
            
            ソースコード
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
template<class T> constexpr auto chmax(T& x, T a) { x = max(x, a); }
typedef long long ll;
int T, N;
int c[101], v, vsum[11];
int dp[2][10010];
int main() {
  cin >> T >> N;
  rep(i, N) cin >> c[i];
  rep(atidx, N) {
    int* curr = dp[atidx&1], *next = dp[(atidx+1)&1];
    cin >> v;
    rep(repeat, 10) { vsum[repeat+1] = vsum[repeat] + v; v /= 2; }
    rep(time, T+1) rep(repeat, 11) {
      int ntime = time + repeat * c[atidx];
      if(ntime <= T) {
        chmax(next[ntime], curr[time] + vsum[repeat]);
      }
    }
  }
  cout << *max_element(dp[N&1], dp[N&1] + T+1) << endl;
  return 0;
}
            
            
            
        