結果
| 問題 | No.249 N言っちゃダメゲーム (2) | 
| コンテスト | |
| ユーザー |  koyumeishi | 
| 提出日時 | 2015-07-24 23:12:58 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 930 bytes | 
| コンパイル時間 | 931 ms | 
| コンパイル使用メモリ | 79,940 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-24 22:38:14 | 
| 合計ジャッジ時間 | 1,646 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 2 WA * 1 | 
ソースコード
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;
int dfs(vector<vector<int>>& memo, vector<long long>& n, vector<long long>& k, int t, int x){
	if(t==1000) return 0;
	if(memo[t][x] != 1e9) return memo[t][x];
	bool win = false;
	if(n[t] <= k[t]) win = true;
	else if((n[t]-1) % (k[t]+1) != 0) win = true;
	int ret = dfs(memo, n,k, t+1, x) + (x==0?-1:+1);	//lose
	if(win){
		int next = dfs(memo, n,k, t+1, x^1) + (x==0?+1:-1);	//win
		if(x == 0){
			ret = max(ret, next);
		}else{
			ret = min(ret, next);
		}
	}
	return memo[t][x] = ret;
}
int main(){
	int x = 1000;
	vector<long long> n(x), k(x);
	vector<vector<int>> memo(x+1, vector<int>(2,1e9));
	for(int i=0; i<x; i++){
		cin >> n[i] >> k[i];
	}
	int ans = dfs(memo, n,k, 0,0)/2 + 500;
	cout << ans << endl;
	return 0;
}
            
            
            
        