結果
問題 | No.60 魔法少女 |
ユーザー | pekempey |
提出日時 | 2016-03-28 17:02:36 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 130 ms / 5,000 ms |
コード長 | 1,028 bytes |
コンパイル時間 | 1,643 ms |
コンパイル使用メモリ | 162,876 KB |
実行使用メモリ | 29,932 KB |
最終ジャッジ日時 | 2024-04-10 05:07:24 |
合計ジャッジ時間 | 3,802 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
11,720 KB |
testcase_01 | AC | 3 ms
11,720 KB |
testcase_02 | AC | 2 ms
11,724 KB |
testcase_03 | AC | 5 ms
24,012 KB |
testcase_04 | AC | 80 ms
29,420 KB |
testcase_05 | AC | 66 ms
28,848 KB |
testcase_06 | AC | 121 ms
29,836 KB |
testcase_07 | AC | 98 ms
29,828 KB |
testcase_08 | AC | 60 ms
28,172 KB |
testcase_09 | AC | 31 ms
28,340 KB |
testcase_10 | AC | 118 ms
29,220 KB |
testcase_11 | AC | 15 ms
28,636 KB |
testcase_12 | AC | 48 ms
29,932 KB |
testcase_13 | AC | 130 ms
28,784 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:35:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 35 | scanf("%d %d %d", &xs[i], &ys[i], &hp[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:42:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 42 | scanf("%d %d %d %d %d", &x, &y, &w, &h, &d); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; long long bit[2020][2020]; void update(int y, int x, long long v) { for (int i = y; i < 2020; i += i & -i) { for (int j = x; j < 2020; j += j & -j) { bit[i][j] += v; } } } long long query(int y, int x) { long long result = 0; for (int i = y; i > 0; i -= i & -i) { for (int j = x; j > 0; j -= j & -j) { result += bit[i][j]; } } return result; } int main() { int n, k; cin >> n >> k; const int offset = 510; vector<int> xs(n); vector<int> ys(n); vector<int> hp(n); for (int i = 0; i < n; i++) { scanf("%d %d %d", &xs[i], &ys[i], &hp[i]); xs[i] += offset; ys[i] += offset; } for (int i = 0; i < k; i++) { int x, y, w, h, d; scanf("%d %d %d %d %d", &x, &y, &w, &h, &d); x += offset; y += offset; update(y, x, d); update(y + h + 1, x, -d); update(y, x + w + 1, -d); update(y + h + 1, x + w + 1, d); } long long ans = 0; for (int i = 0; i < n; i++) { ans += max(0ll, hp[i] - query(ys[i], xs[i])); } cout << ans << endl; }