結果
| 問題 |
No.60 魔法少女
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-15 02:03:56 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 105 ms / 5,000 ms |
| コード長 | 2,419 bytes |
| コンパイル時間 | 1,287 ms |
| コンパイル使用メモリ | 131,536 KB |
| 最終ジャッジ日時 | 2025-01-11 20:47:56 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:71:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
71 | int n, kkt; scanf("%d %d", &n, &kkt);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:73:28: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
73 | int x, y, HP; scanf("%d %d %d", &x, &y, &HP);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:79:37: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
79 | int sh, sw, gh, gw, d; scanf("%d %d %d %d %d", &sh, &sw, &gh, &gw, &d);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
constexpr int D = 500;
template<class T>
struct imos2D {
vector<vector<T>> data;
int H, W;
imos2D() :H(0), W(0) {}
imos2D(int _H, int _W) :H(_H), W(_W) { data.assign(H, vector<T>(W)); }
void add(int sh, int sw, int gh, int gw, T x) {
data[sh][sw] += x;
if(gw < W) data[sh][gw] -= x;
if(gh < H) data[gh][sw] -= x;
if(gh <H and gw < W) data[gh][gw] += x;
}
void build() {
for (int i = 0; i < H; i++) for (int j = 0; j < W - 1; j++) data[i][j + 1] += data[i][j];
for (int j = 0; j < W; j++) for (int i = 0; i < H - 1; i++) data[i + 1][j] += data[i][j];
}
vector<T>& operator[](int i) { return data[i]; }
};
int main()
{
/*
cin.tie(nullptr);
ios::sync_with_stdio(false);
*/
constexpr int H = 1001, W = 1001;
vector<vector<ll>> a(H, vector<ll>(W));
int n, kkt; scanf("%d %d", &n, &kkt);
for (int i = 0; i < n; i++) {
int x, y, HP; scanf("%d %d %d", &x, &y, &HP);
x += D, y += D;
a[x][y] += HP;
}
imos2D<ll> imos(H, W);
while (kkt--) {
int sh, sw, gh, gw, d; scanf("%d %d %d %d %d", &sh, &sw, &gh, &gw, &d);
sh += D, sw += D, gh += sh, gw += sw;
imos.add(sh, sw, gh + 1, gw + 1, -d);
}
imos.build();
ll res = 0;
for (int i = 0; i < H; i++)for (int j = 0; j < W; j++) res += max(0LL, imos[i][j] + a[i][j]);
cout << res << endl;
return 0;
}