結果
問題 | No.60 魔法少女 |
ユーザー | vain0 |
提出日時 | 2015-06-23 11:24:56 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,117 bytes |
コンパイル時間 | 1,051 ms |
コンパイル使用メモリ | 84,716 KB |
実行使用メモリ | 5,012 KB |
最終ジャッジ日時 | 2023-09-22 00:14:11 |
合計ジャッジ時間 | 8,301 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 267 ms
4,380 KB |
testcase_05 | AC | 491 ms
4,884 KB |
testcase_06 | AC | 1,312 ms
5,004 KB |
testcase_07 | WA | - |
testcase_08 | AC | 337 ms
4,376 KB |
testcase_09 | AC | 78 ms
4,376 KB |
testcase_10 | AC | 1,181 ms
4,748 KB |
testcase_11 | AC | 10 ms
4,380 KB |
testcase_12 | AC | 240 ms
4,472 KB |
testcase_13 | AC | 1,406 ms
5,012 KB |
ソースコード
#include <cassert> #include <functional> #include <set> #include <ctime> #include <cmath> #include <climits> #include <cstring> #include <string> #include <queue> #include <map> #include <vector> #include <algorithm> #include <iostream> #include <cstdio> #ifndef ONLINE_JUDGE //POJ # include <complex> # include <random> # include <array> # define mkt make_tuple # define empb emplace_back #endif #ifdef _LOCAL # include "for_local.h" #endif using namespace std; typedef unsigned int uint; typedef long long ll; typedef unsigned long long ull; #define repi(_I, _B, _E) for(int _I = (_B); (_I) < (_E); ++ (_I)) #define rep(_I, _N) for(int _I = 0; (_I) < (_N); ++ (_I)) #define mkp make_pair #define all(_X) (_X).begin(), (_X).end() inline int scani() { int n; scanf("%d", &n); return n; } int n, k; struct Enemy { int x, y, hp; }; struct Attack { int x, y, w, h, d; }; int const MAX_X = 1001, MAX_Y = 1001; int const BX = 32; //1つのバケツがカバーするxの幅 vector<vector<Enemy>> buckets; bool operator < (Enemy const& lhs, Enemy const& rhs) { return (lhs.y - rhs.y) < 0; } void deal(vector<Enemy>& b, Attack& a) { auto&& lb = lower_bound(all(b), Enemy { 0, a.y, 0 }); auto&& ub = upper_bound(all(b), Enemy { 0, a.y + a.h + 1, 0 }); for ( auto it = lb; it != ub; ) { auto& e = *it; if ( a.x <= e.x && e.x <= a.x + a.w ) { if ( e.hp >= 0 ) { e.hp -= a.d; } } ++it; continue; } } signed main() { int n, k; scanf("%d %d", &n, &k); buckets.resize(MAX_X / BX + 5); for ( auto& b : buckets ) { b.reserve(n / buckets.size()); } rep(ie, n) { int x, y, hp; scanf("%d %d %d", &x, &y, &hp); x += 500; y += 500; buckets[x / BX].push_back(Enemy {x, y, hp}); } for ( auto& b : buckets ) { sort(all(b)); } rep(ia, k) { Attack a; scanf("%d %d %d %d %d", &a.x, &a.y, &a.w, &a.h, &a.d); a.x += 500; a.y += 500; repi(i, a.x / BX, min<int>((a.x + a.w + 1 + BX - 1) / BX, buckets.size())) { deal(buckets[i], a); } } ll total = 0; for ( auto& b : buckets ) { for ( auto& e : b ) { if ( e.hp > 0 ) { total += e.hp; } } } cout << total << endl; return 0; }