結果

問題 No.511 落ちゲー 〜手作業のぬくもり〜
ユーザー koba-e964koba-e964
提出日時 2017-04-29 00:17:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 184 ms / 4,000 ms
コード長 2,056 bytes
コンパイル時間 876 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 4,600 KB
最終ジャッジ日時 2023-08-16 03:07:28
合計ジャッジ時間 3,756 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,384 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,388 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 3 ms
4,384 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 4 ms
4,384 KB
testcase_28 AC 3 ms
4,508 KB
testcase_29 AC 182 ms
4,576 KB
testcase_30 AC 152 ms
4,600 KB
testcase_31 AC 140 ms
4,384 KB
testcase_32 AC 153 ms
4,380 KB
testcase_33 AC 165 ms
4,380 KB
testcase_34 AC 159 ms
4,384 KB
testcase_35 AC 183 ms
4,536 KB
testcase_36 AC 184 ms
4,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

const int W = 320;
const int N = W * W;

ll big[W];
ll small[N];
ll ma[W];


int won[N];

int main(void){
  int n, w;
  ll h;
  cin >> n >> w >> h;
  REP(i, 0, w) {
    won[i] = -1;
  }
  REP(i, 0, n) {
    int a, x;
    ll b;
    cin >> x >> b >> a;
    a--;
    int e = a + x;
    int l = (a + W - 1) / W;
    int r = e / W;
    if (l >= r) {
      // manually
      REP(j, a, e) {
	small[j] += b;
	ma[j / W] = max(ma[j / W], small[j] + big[j / W]);
	ll res = big[j / W] + small[j];
	if (res >= h && res - b < h) {
	  won[j] = i % 2;
	}
      }
    } else {
      REP(j, a, l * W) {
	small[j] += b;
	ma[j / W] = max(ma[j / W], small[j] + big[j / W]);
	ll res = big[j / W] + small[j];
	if (res >= h && res - b < h) {
	  won[j] = i % 2;
	}
      }
      REP(j, l, r) {
	big[j] += b;
	ma[j] += b;
	if (ma[j] >= h  && ma[j] - b < h) {
	  REP(k, 0, W) {
	    int idx = j * W + k;
	    ll res = big[j] + small[idx];
	    if (res >= h && res - b < h) {
	      won[idx] = i % 2;
	    }
	  }
	}
	
      }
      REP(j, r * W, e) {
	small[j] += b;
	ma[j / W] = max(ma[j / W], small[j] + big[j / W]);
	ll res = big[j / W] + small[j];
	if (res >= h && res - b < h) {
	  won[j] = i % 2;
	}
      }
    }
  }
  int cnt = 0;
  REP(i, 0, w) {
    if (won[i] == 0) cnt += 1;
    //cout << "won[" << i << "]=" << won[i] << endl;
  }
  if (cnt * 2 == w) {
    cout << "DRAW" << endl;
  } else if (cnt * 2 < w) {
    cout << "B" << endl;
  } else {
    cout << "A" << endl;
  }
}
0