結果

問題 No.511 落ちゲー 〜手作業のぬくもり〜
ユーザー shimasuzu@live.jp
提出日時 2017-04-28 23:38:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 868 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 24,064 KB
実行使用メモリ 13,888 KB
最終ジャッジ日時 2024-09-13 18:40:31
合計ジャッジ時間 6,323 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4 WA * 1
other AC * 15 WA * 9 TLE * 1 -- * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int solve()’:
main.cpp:22:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |                 scanf("%d%d%d", &a, &b, &x);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<cstdio>
#include<cstring>


typedef long long ll;


int n, w;
ll h;

ll bh[100000+1];


int solve(void)
{
	int a, b, x, i, j, ret=-1;
	int score[2]={0, 0};

	memset(bh, 0, sizeof(bh));
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d", &a, &b, &x);
		if(ret>=0) break;

		for(j=0;j<a;j++)
		{
			if(bh[x+j]<h)
			{
				bh[x+j]+=b;
				if(bh[x+j]>=h)
				{
					score[i%2]++;
					if(score[0]+score[1]>=w)
					{
						if(score[0]==score[1]) ret=0;
						if(score[0]>score[1]) ret=1;
						if(score[0]<score[1]) ret=2;
					}
				}
			}
		}
	}
/*
printf("n=%d h=%lld w=%d\n", n, h, w);
printf("score=(%d,%d) ret=%d\n", score[0], score[1], ret);
for(j=1;j<=w;j++) printf("%lld ", bh[j]);
printf("\n");
*/
	return ret;
}


int main(void)
{
	char result[][5]={"DRAW", "A", "B"};

	while(scanf("%d%d%lld", &n, &w, &h)==3)
	{
		printf("%s\n", result[solve()]);
	}
	return 0;
}
0