結果

問題 No.60 魔法少女
ユーザー renjyaku_intrenjyaku_int
提出日時 2020-10-16 19:33:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 258 ms / 5,000 ms
コード長 2,364 bytes
コンパイル時間 3,524 ms
コンパイル使用メモリ 203,464 KB
実行使用メモリ 13,236 KB
最終ジャッジ日時 2023-09-28 02:27:21
合計ジャッジ時間 5,769 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
10,928 KB
testcase_01 AC 7 ms
10,916 KB
testcase_02 AC 7 ms
10,956 KB
testcase_03 AC 8 ms
10,952 KB
testcase_04 AC 176 ms
11,304 KB
testcase_05 AC 116 ms
12,960 KB
testcase_06 AC 258 ms
12,976 KB
testcase_07 AC 190 ms
12,544 KB
testcase_08 AC 109 ms
12,176 KB
testcase_09 AC 55 ms
11,424 KB
testcase_10 AC 230 ms
13,208 KB
testcase_11 AC 15 ms
11,376 KB
testcase_12 AC 78 ms
12,504 KB
testcase_13 AC 248 ms
13,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#include <tourist>
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//g++ yarudake.cpp -std=c++17 -I .
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<vector<ll>> d(1001, vector<ll>(1001, 0));
    vector<ll> x(n), y(n), h(n);
    rep(i, n) cin >> x[i] >> y[i] >> h[i];
    rep(i, n)
    {
        x[i] += 500;
        y[i] += 500;
    }
    rep(i, k)
    {
        ll a, b, ww, hh, dd;
        cin >> a >> b >> ww >> hh >> dd;
        a += 500;
        b += 500;
        rep(j, ww + 1)
        {
            if (a + j <= 1000)
            {
                d[a + j][b] += dd;
                if (b + hh + 1 <= 1000)
                    d[a + j][b + hh + 1] -= dd;
            }
        }
    }
    rep(i, 1001)
    {
        rep(j, 1000)
        {
            d[i][j + 1] += d[i][j];
        }
    }
    /*
    rep(i, 10)
    {
        rep(j, 10)
        {
            cout << d[i + 500 - 5][j + 500 - 5] << " ";
        }
        cout << "\n";
    }*/
    ll ans = 0;
    rep(i, n)
    {
        ans += max(ll(0), h[i] - d[x[i]][y[i]]);
    }
    cout << ans << "\n";
}
0