結果
問題 | No.1490 スライムと爆弾 |
ユーザー | siman |
提出日時 | 2022-06-29 02:37:16 |
言語 | C++17(clang) (17.0.6 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 261 ms / 2,000 ms |
コード長 | 1,793 bytes |
コンパイル時間 | 1,542 ms |
コンパイル使用メモリ | 105,440 KB |
実行使用メモリ | 39,312 KB |
最終ジャッジ日時 | 2023-08-14 03:46:15 |
合計ジャッジ時間 | 6,646 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 11 ms
35,028 KB |
testcase_01 | AC | 11 ms
35,072 KB |
testcase_02 | AC | 10 ms
34,976 KB |
testcase_03 | AC | 10 ms
35,064 KB |
testcase_04 | AC | 10 ms
35,016 KB |
testcase_05 | AC | 10 ms
34,956 KB |
testcase_06 | AC | 11 ms
34,952 KB |
testcase_07 | AC | 11 ms
34,960 KB |
testcase_08 | AC | 10 ms
35,076 KB |
testcase_09 | AC | 10 ms
35,100 KB |
testcase_10 | AC | 9 ms
35,076 KB |
testcase_11 | AC | 11 ms
35,068 KB |
testcase_12 | AC | 10 ms
35,072 KB |
testcase_13 | AC | 122 ms
37,128 KB |
testcase_14 | AC | 146 ms
37,152 KB |
testcase_15 | AC | 76 ms
36,108 KB |
testcase_16 | AC | 113 ms
36,960 KB |
testcase_17 | AC | 59 ms
35,708 KB |
testcase_18 | AC | 147 ms
37,268 KB |
testcase_19 | AC | 129 ms
36,960 KB |
testcase_20 | AC | 94 ms
36,524 KB |
testcase_21 | AC | 55 ms
35,756 KB |
testcase_22 | AC | 131 ms
37,224 KB |
testcase_23 | AC | 9 ms
35,024 KB |
testcase_24 | AC | 10 ms
35,012 KB |
testcase_25 | AC | 166 ms
37,412 KB |
testcase_26 | AC | 165 ms
37,368 KB |
testcase_27 | AC | 167 ms
37,404 KB |
testcase_28 | AC | 117 ms
36,972 KB |
testcase_29 | AC | 116 ms
37,028 KB |
testcase_30 | AC | 261 ms
39,312 KB |
ソースコード
#include <cassert> #include <cmath> #include <algorithm> #include <iostream> #include <iomanip> #include <climits> #include <map> #include <queue> #include <set> #include <cstring> #include <vector> using namespace std; typedef long long ll; ll S[2010][2010]; int main() { int H, W, N, M; cin >> H >> W >> N >> M; int T[N]; int U[N]; int L[N]; int R[N]; ll A[N]; for (int i = 0; i < N; ++i) { cin >> T[i] >> U[i] >> L[i] >> R[i] >> A[i]; } int X[M]; int Y[M]; int B[M]; ll C[M]; for (int i = 0; i < M; ++i) { cin >> Y[i] >> X[i] >> B[i] >> C[i]; } memset(S, 0, sizeof(S)); for (int i = 0; i < M; ++i) { int y = Y[i]; int x = X[i]; int b = B[i]; ll c = C[i]; int ly = max(1, y - b); int lx = max(1, x - b); int ry = min(H, y + b); int rx = min(W, x + b); // fprintf(stderr, "(%d, %d) - (%d, %d)\n", ly, lx, ry, rx); S[ly][lx] += c; S[ly][rx + 1] -= c; S[ry + 1][lx] -= c; S[ry + 1][rx + 1] += c; } for (int y = 0; y <= H; ++y) { ll sum = 0; for (int x = 1; x <= W; ++x) { sum += S[y][x]; S[y][x] = sum + S[y][x - 1]; } } for (int x = 0; x <= W; ++x) { ll sum = 0; for (int y = 1; y <= H; ++y) { sum += S[y][x]; S[y][x] = sum + S[y - 1][x]; } } /* for (int y = 0; y <= H; ++y) { for (int x = 0; x <= W; ++x) { cerr << S[y][x] << " "; } cerr << endl; } */ int ans = 0; for (int i = 0; i < N; ++i) { int ly = T[i]; int ry = U[i]; int lx = L[i]; int rx = R[i]; // fprintf(stderr, "(%d, %d) - (%d, %d)\n", ly, lx, ry, rx); ll damage = S[ry][rx] - S[ry][lx - 1] - S[ly - 1][rx] + S[ly - 1][lx - 1]; if (damage < A[i]) ++ans; } cout << ans << endl; return 0; }