結果

問題 No.1490 スライムと爆弾
ユーザー 👑 NachiaNachia
提出日時 2021-04-23 21:33:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 1,099 bytes
コンパイル時間 669 ms
コンパイル使用メモリ 78,396 KB
実行使用メモリ 36,560 KB
最終ジャッジ日時 2023-09-17 11:50:15
合計ジャッジ時間 5,128 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
34,800 KB
testcase_01 AC 47 ms
34,844 KB
testcase_02 AC 47 ms
34,868 KB
testcase_03 AC 47 ms
34,804 KB
testcase_04 AC 48 ms
35,104 KB
testcase_05 AC 48 ms
35,052 KB
testcase_06 AC 47 ms
34,804 KB
testcase_07 AC 48 ms
34,844 KB
testcase_08 AC 47 ms
34,852 KB
testcase_09 AC 48 ms
34,836 KB
testcase_10 AC 47 ms
34,896 KB
testcase_11 AC 48 ms
34,976 KB
testcase_12 AC 48 ms
34,896 KB
testcase_13 AC 72 ms
35,108 KB
testcase_14 AC 74 ms
36,292 KB
testcase_15 AC 51 ms
34,868 KB
testcase_16 AC 70 ms
35,532 KB
testcase_17 AC 48 ms
34,992 KB
testcase_18 AC 77 ms
36,168 KB
testcase_19 AC 68 ms
35,788 KB
testcase_20 AC 57 ms
35,144 KB
testcase_21 AC 43 ms
34,784 KB
testcase_22 AC 76 ms
36,040 KB
testcase_23 AC 47 ms
34,780 KB
testcase_24 AC 47 ms
34,860 KB
testcase_25 AC 94 ms
36,560 KB
testcase_26 AC 94 ms
36,324 KB
testcase_27 AC 92 ms
36,500 KB
testcase_28 AC 64 ms
34,832 KB
testcase_29 AC 65 ms
34,836 KB
testcase_30 AC 118 ms
36,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)

struct Slime{ int l,t,r,b,a; };

int H,W;
int N,M;

vector<Slime> A;
ll X[2002][2002] = {};

int main(){
  scanf("%d%d",&H,&W);
  scanf("%d%d",&N,&M);
  A.resize(N);
  rep(i,N){
    int l,t,r,b,a; scanf("%d%d%d%d%d",&t,&b,&l,&r,&a); l--; t--;
    A[i] = {l,t,r,b,a};
  }
  rep(i,M){
    int x,y,w,a; scanf("%d%d%d%d",&x,&y,&w,&a); x--; y--;
    int l = max(0,x-w);
    int r = min(H,x+1+w);
    int t = max(0,y-w);
    int b = min(W,y+1+w);
    X[l+1][t+1] += a;
    X[l+1][b+1] -= a;
    X[r+1][t+1] -= a;
    X[r+1][b+1] += a;
  }
  rep(i,2001) rep(j,2002) X[i+1][j] += X[i][j];
  rep(i,2002) rep(j,2001) X[i][j+1] += X[i][j];
  rep(i,2001) rep(j,2002) X[i+1][j] += X[i][j];
  rep(i,2002) rep(j,2001) X[i][j+1] += X[i][j];
  int ans = 0;
  for(auto s : A){
    ll damage = 0;
    damage += X[s.b][s.r];
    damage -= X[s.b][s.l];
    damage -= X[s.t][s.r];
    damage += X[s.t][s.l];
    if(damage < s.a) ans++;
  }
  printf("%d\n",ans);
  return 0;
}
0