結果
| 問題 |
No.60 魔法少女
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-11-09 21:30:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 232 ms / 5,000 ms |
| コード長 | 1,611 bytes |
| コンパイル時間 | 539 ms |
| コンパイル使用メモリ | 56,968 KB |
| 実行使用メモリ | 22,332 KB |
| 最終ジャッジ日時 | 2024-12-31 08:54:11 |
| 合計ジャッジ時間 | 3,142 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 |
ソースコード
#include <iostream>
using namespace std;
void rc(int v,int mn,int mx){if(v<mn||mx<v){cerr<<"error"<<endl;exit(1);}}
const int OFFSET = 500;
const int SIZE = 1555;
int h[SIZE][SIZE];
int d[SIZE][SIZE];
bool used[SIZE][SIZE];
int main(){
int N, K;
cin >> N >> K;
rc(N, 1, 100000);
rc(K, 1, 100000);
for(int i=0;i<N;i++){
int X, Y, H;
cin >> X >> Y >> H;
rc(X, -500, 500);
rc(Y, -500, 500);
rc(H, 1, 10000);
X += OFFSET;
Y += OFFSET;
if(used[X][Y]){
cerr << "error" << endl;
exit(1);
} else {
used[X][Y] = true;
}
h[Y][X] = H;
}
for(int i=0;i<K;i++){
int AX, AY, W, H, D;
cin >> AX >> AY >> W >> H >> D;
rc(AX, -500, 500);
rc(AY, -500, 500);
rc(W, 1, 500);
rc(H, 1, 500);
rc(D, 1, 10000);
AX += OFFSET;
AY += OFFSET;
d[AY][AX] += D;
d[AY][AX+W+1] -= D;
d[AY+H+1][AX] -= D;
d[AY+H+1][AX+W+1] += D;
}
for(int Y=0;Y<SIZE;Y++){
for(int X=1;X<SIZE;X++){
d[Y][X] += d[Y][X-1];
}
}
for(int X=0;X<SIZE;X++){
for(int Y=1;Y<SIZE;Y++){
d[Y][X] += d[Y-1][X];
}
}
int res = 0;
for(int Y=0;Y<SIZE;Y++)for(int X=0;X<SIZE;X++){
int rest = h[Y][X] - d[Y][X];
if(rest > 0)res += rest;
}
cout << res << endl;
return 0;
}