結果
| 問題 |
No.511 落ちゲー 〜手作業のぬくもり〜
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-29 00:17:55 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 175 ms / 4,000 ms |
| コード長 | 2,056 bytes |
| コンパイル時間 | 704 ms |
| コンパイル使用メモリ | 88,192 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-24 12:40:04 |
| 合計ジャッジ時間 | 3,118 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 32 |
ソースコード
#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;
}
}