結果
| 問題 |
No.60 魔法少女
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2022-12-20 17:22:47 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 172 ms / 5,000 ms |
| コード長 | 1,108 bytes |
| コンパイル時間 | 1,190 ms |
| コンパイル使用メモリ | 145,512 KB |
| 実行使用メモリ | 18,944 KB |
| 最終ジャッジ日時 | 2024-11-18 01:55:37 |
| 合計ジャッジ時間 | 3,702 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
using namespace std;
int main(){
long long N, K, ans=0, X, Y, W, H, D, P;
cin >> N >> K;
vector<vector<long long>> HP(1002, vector<long long>(1002)), DM(1002, vector<long long>(1002));
for (int i=0; i<N; i++){
cin >> X >> Y >> P;
X += 501; Y += 501;
HP[X][Y] += P;
}
for (int i=0; i<K; i++){
cin >> X >> Y >> W >> H >> D;
X += 501; Y += 501;
DM[X][Y] += D;
if (X+W+1 <= 1001) DM[X+W+1][Y] -= D;
if (Y+H+1 <= 1001) DM[X][Y+H+1] -= D;
if (X+W+1 <= 1001 && Y+H+1 <= 1001) DM[X+W+1][Y+H+1] += D;
}
for (int i=0; i<=1000; i++){
for (int j=0; j<=1000; j++){
DM[i+1][j+1] += DM[i+1][j] + DM[i][j+1] - DM[i][j];
}
}
for (int i=0; i<=1001; i++){
for (int j=0; j<=1001; j++) ans += max(0LL, HP[i][j] - DM[i][j]);
}
cout << ans << endl;
return 0;
}
srjywrdnprkt