結果

問題 No.60 魔法少女
ユーザー GOTKAKO
提出日時 2025-06-27 17:22:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 90 ms / 5,000 ms
コード長 888 bytes
コンパイル時間 2,236 ms
コンパイル使用メモリ 203,468 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2025-06-27 17:22:18
合計ジャッジ時間 4,283 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N,K; cin >> N >> K;
    vector<tuple<int,int,int>> XY(N);
    for(auto &[x,y,h] : XY) cin >> x >> y >> h,x += 500,y += 500;
    
    int n = 1000;
    vector<vector<int>> S(n+1,vector<int>(n+1));
    while(K--){
        int x,y,w,h,d; cin >> x >> y >> w >> h >> d;
        x += 500,y += 500,w++,h++;
        S.at(x).at(y) += d;
        if(x+w <= n) S.at(x+w).at(y) -= d;
        if(y+h <= n) S.at(x).at(y+h) -= d;
        if(x+w <= n && y+h <= n) S.at(x+w).at(y+h) += d;
    }
    for(int i=0; i<=n; i++) for(int k=1; k<=n; k++) S.at(i).at(k) += S.at(i).at(k-1);
    for(int i=1; i<=n; i++) for(int k=0; k<=n; k++) S.at(i).at(k) += S.at(i-1).at(k);

    int answer = 0;
    for(auto [x,y,h] : XY) answer += max(0,h-S.at(x).at(y));
    cout << answer << endl;
}
0