結果

問題 No.60 魔法少女
ユーザー たこしたこし
提出日時 2014-11-13 15:44:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 185 ms / 5,000 ms
コード長 1,803 bytes
コンパイル時間 669 ms
コンパイル使用メモリ 88,104 KB
実行使用メモリ 22,248 KB
最終ジャッジ日時 2023-08-30 03:23:49
合計ジャッジ時間 3,072 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
21,936 KB
testcase_01 AC 19 ms
21,876 KB
testcase_02 AC 19 ms
21,904 KB
testcase_03 AC 19 ms
21,948 KB
testcase_04 AC 108 ms
21,748 KB
testcase_05 AC 115 ms
22,248 KB
testcase_06 AC 179 ms
22,116 KB
testcase_07 AC 136 ms
21,988 KB
testcase_08 AC 93 ms
21,924 KB
testcase_09 AC 50 ms
21,784 KB
testcase_10 AC 170 ms
22,084 KB
testcase_11 AC 34 ms
21,792 KB
testcase_12 AC 86 ms
21,976 KB
testcase_13 AC 185 ms
22,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define INF 1000000000
#define EPS 1e-9
#define PI acos(-1)

typedef long long ll;
typedef pair<int, int> P;

#define MAX_N 100000
#define MAX_K 100000

#define MAX_F 2000

int N, K;
int X[MAX_N], Y[MAX_N], HP[MAX_N];
int AX[MAX_K], AY[MAX_K], W[MAX_K], H[MAX_K], D[MAX_K];

const int GETA = 600;
int filed[MAX_F][MAX_F];

int main(){

  cin >> N >> K;
  for(int i = 0; i < N; i++){
    cin >> X[i] >> Y[i] >> HP[i];
    X[i] += GETA;
    Y[i] += GETA;
  }
  for(int i = 0; i < K; i++){
    cin >> AX[i] >> AY[i] >> W[i] >> H[i] >> D[i];
    AX[i] += GETA;
    AY[i] += GETA;
  }

  //フィールドデータの設定
  memset(filed,0,sizeof(filed));

  for(int i = 0; i < K; i++){
    filed[AX[i]][AY[i]] += D[i];
    filed[AX[i]+W[i]+1][AY[i]] -= D[i];
    filed[AX[i]][AY[i]+H[i]+1] -= D[i];
    filed[AX[i]+W[i]+1][AY[i]+H[i]+1] += D[i];
  }

  //横方向への累積和
  for(int i = 1; i < MAX_F; i++){
    for(int j = 0; j < MAX_F; j++){
      filed[i][j] += filed[i-1][j];
    }
  }

  //縦方向への累積和
  for(int i = 0; i < MAX_F; i++){
    for(int j = 1; j < MAX_F; j++){
      filed[i][j] += filed[i][j-1];
    }
  }

  int ans = 0;
  for(int i = 0; i < N; i++){
    int tmp = HP[i] - filed[X[i]][Y[i]];
    if(tmp > 0)
      ans += tmp;
  }

  cout << ans << endl;

  return 0;
  
}
0