結果

問題 No.60 魔法少女
ユーザー tkmst201tkmst201
提出日時 2017-05-22 20:54:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 87 ms / 5,000 ms
コード長 1,355 bytes
コンパイル時間 1,319 ms
コンパイル使用メモリ 160,692 KB
実行使用メモリ 12,940 KB
最終ジャッジ日時 2023-10-19 14:13:12
合計ジャッジ時間 3,556 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
12,688 KB
testcase_01 AC 9 ms
12,688 KB
testcase_02 AC 9 ms
12,688 KB
testcase_03 AC 9 ms
12,688 KB
testcase_04 AC 53 ms
12,688 KB
testcase_05 AC 53 ms
12,916 KB
testcase_06 AC 87 ms
12,912 KB
testcase_07 AC 65 ms
12,816 KB
testcase_08 AC 44 ms
12,764 KB
testcase_09 AC 24 ms
12,688 KB
testcase_10 AC 79 ms
12,916 KB
testcase_11 AC 16 ms
12,688 KB
testcase_12 AC 39 ms
12,816 KB
testcase_13 AC 87 ms
12,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:31:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |                 scanf("%d %d %d", X + i, Y + i, HP + i);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:38:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 |                 scanf("%d %d %d %d %d", &ax, &ay, &w, &h, &d);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int N, K;
int X[112345], Y[112345], HP[112345];
ll damage[1002][1002];

int main() {
	cin >> N >> K;
	REP(i, N) {
		scanf("%d %d %d", X + i, Y + i, HP + i);
		X[i] += 500;
		Y[i] += 500;
	}
	
	REP(i, K) {
		int ax, ay, w, h, d;
		scanf("%d %d %d %d %d", &ax, &ay, &w, &h, &d);
		
		ax += 500;
		ay += 500;
		
		damage[ay][ax] += d;
		damage[min(1001, ay + h + 1)][ax] -= d;
		damage[ay][min(1001, ax + w + 1)] -= d;
		damage[min(1001, ay + h + 1)][min(1001, ax + w + 1)] += d;
	}
	
	REP(i, 1001) FOR(j, 1, 1001) damage[i][j] += damage[i][j - 1];
	REP(j, 1001) FOR(i, 1, 1001) damage[i][j] += damage[i - 1][j];
	
	ll ans = 0;
	REP(i, N) {
		int now = damage[Y[i]][X[i]];
		ans += max(0, HP[i] - now);
	}
	cout << ans << endl;
	
	return 0;
}
0