結果
問題 | No.60 魔法少女 |
ユーザー |
|
提出日時 | 2017-07-14 20:15:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 271 ms / 5,000 ms |
コード長 | 2,046 bytes |
コンパイル時間 | 1,599 ms |
コンパイル使用メモリ | 169,640 KB |
実行使用メモリ | 21,184 KB |
最終ジャッジ日時 | 2024-10-07 21:53:19 |
合計ジャッジ時間 | 4,392 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 |
ソースコード
#include <bits/stdc++.h> #define show(x) cout << #x << " = " << x << endl using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "sz=" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template <typename S, typename T> ostream& operator<<(ostream& os, const pair<S, T>& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = 1e9 + 7; template <typename T> constexpr T INF = numeric_limits<T>::max() / 100; constexpr ll HALF = 500; constexpr ll MAX = HALF * 2; ll imos[MAX + 1][MAX + 1]; ll sum[MAX + 1][MAX + 1]; struct Enemy { Enemy() = default; Enemy(ll hp, ll x, ll y) : hp(hp), x(x), y(y) {} ll hp; ll x; ll y; }; int main() { ll N, K; cin >> N >> K; vector<Enemy> enemy(N); for (ll i = 0; i < N; i++) { ll x, y, hp; cin >> x >> y >> hp; enemy[i] = Enemy{hp, x + HALF, y + HALF}; } for (ll i = 0; i < K; i++) { ll ax, ay, w, h, d; cin >> ax >> ay >> w >> h >> d; const ll starty = ay + HALF; const ll endy = min(ay + h + HALF, MAX); const ll startx = ax + HALF; const ll endx = min(ax + w + HALF, MAX); for (ll y = starty; y <= endy; y++) { imos[y][startx] += d; if (endx < MAX) { imos[y][endx + 1] -= d; } } } for (ll y = 0; y <= MAX; y++) { sum[y][0] = imos[y][0]; } for (ll y = 0; y <= MAX; y++) { for (ll x = 1; x <= MAX; x++) { sum[y][x] = sum[y][x - 1] + imos[y][x]; } } ll res = 0; for (ll i = 0; i < N; i++) { const ll hp = enemy[i].hp; const ll y = enemy[i].y; const ll x = enemy[i].x; if (sum[y][x] < hp) { res += (hp - sum[y][x]); } } cout << res << endl; return 0; }