提出 #68171756


ソースコード 拡げる

//#pragma GCC optimize("O3")
//#pragma GCC optimization("Ofast,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define endl '\n'
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ext exit(0)
#define INF 1000000000000000000
#define DIMBIT 32
#define fsort(a) sort(a.begin(), a.end())
#define fsortc(a, b) sort(a.begin(), a.end(), b)
#define pb push_back
#define frev(a) reverse(a.begin(), a.end())
#define fr first
#define se second
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
typedef pair<ll, ll> llpair;
#define ull unsigned long long
typedef pair<ll, ull> upair;
#define sz(a) int(a.size())
#define ld long double
#define db double
#define vll vector<ll>
#define all(x) x.begin(), x.end()
#define cnt_bit(a) __popcount(static_cast<unsigned long long>(a))
#define vint vector<int>
#define FOR(i, x, n) for(ll i = x; i < n; ++i)
#define rz resize
#define DIM 200007
mt19937 rng(1488);
ll randll(ll l, ll r){return uniform_int_distribution<ll>(l, r)(rng);}

ll n,m;
vector<vll> ms, dp;
ll p[DIM];

bool check(ll i, ll j) {
    if (i>=n || j >= m || j < 0 || i < 0) return 0;
    return 1;
}

int main() {
    speed;
    cin >> n >> m;
    ms.rz(n);
    dp.rz(n);
    FOR(i, 0, n) {
        ms[i].rz(m);
        dp[i].resize(m, INF);
        FOR(j, 0, m) {
            cin >> ms[i][j];
        }
    }
    FOR(i, 0, n+m-1) cin >> p[i];
    dp[n-1][m-1] = 0;
    for (ll i = n-1; i >= 0; --i) {
        for (ll j = m-1; j >= 0; --j) {
            if (check(i+1, j)) dp[i][j] = min(dp[i][j], dp[i+1][j]);
            if (check(i, j+1)) dp[i][j] = min(dp[i][j], dp[i][j+1]);
            dp[i][j] += p[i+j] - ms[i][j];
            dp[i][j] = max(dp[i][j], 0ll);
        }
    }

    cout << dp[0][0] << endl;
    return 0;
}

提出情報

提出日時
問題 E - Hungry Takahashi
ユーザ qreytol
言語 C++ 20 (gcc 12.2)
得点 450
コード長 2064 Byte
結果 AC
実行時間 41 ms
メモリ 26560 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 450 / 450
結果
AC × 3
AC × 46
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt, 03_handmade_05.txt, 03_handmade_06.txt, 03_handmade_07.txt, 03_handmade_08.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3472 KiB
00_sample_01.txt AC 1 ms 3456 KiB
00_sample_02.txt AC 1 ms 3468 KiB
01_random_00.txt AC 24 ms 7820 KiB
01_random_01.txt AC 24 ms 7660 KiB
01_random_02.txt AC 23 ms 7796 KiB
01_random_03.txt AC 24 ms 7820 KiB
01_random_04.txt AC 15 ms 6404 KiB
01_random_05.txt AC 14 ms 6340 KiB
01_random_06.txt AC 14 ms 6416 KiB
01_random_07.txt AC 14 ms 6464 KiB
01_random_08.txt AC 13 ms 6148 KiB
01_random_09.txt AC 14 ms 6240 KiB
01_random_10.txt AC 13 ms 6204 KiB
01_random_11.txt AC 13 ms 6236 KiB
01_random_12.txt AC 14 ms 6072 KiB
01_random_13.txt AC 13 ms 6164 KiB
01_random_14.txt AC 13 ms 6212 KiB
01_random_15.txt AC 13 ms 6208 KiB
01_random_16.txt AC 14 ms 7028 KiB
01_random_17.txt AC 14 ms 7016 KiB
01_random_18.txt AC 14 ms 6980 KiB
01_random_19.txt AC 14 ms 6884 KiB
01_random_20.txt AC 27 ms 15016 KiB
01_random_21.txt AC 26 ms 14880 KiB
01_random_22.txt AC 26 ms 14880 KiB
01_random_23.txt AC 26 ms 14876 KiB
01_random_24.txt AC 41 ms 26480 KiB
01_random_25.txt AC 40 ms 26560 KiB
01_random_26.txt AC 41 ms 26472 KiB
01_random_27.txt AC 40 ms 26540 KiB
02_random2_00.txt AC 9 ms 6200 KiB
02_random2_01.txt AC 10 ms 6192 KiB
02_random2_02.txt AC 11 ms 6312 KiB
02_random2_03.txt AC 13 ms 6076 KiB
02_random2_04.txt AC 13 ms 6076 KiB
02_random2_05.txt AC 13 ms 6236 KiB
03_handmade_00.txt AC 1 ms 3408 KiB
03_handmade_01.txt AC 1 ms 3424 KiB
03_handmade_02.txt AC 1 ms 3340 KiB
03_handmade_03.txt AC 8 ms 6304 KiB
03_handmade_04.txt AC 13 ms 6208 KiB
03_handmade_05.txt AC 14 ms 6208 KiB
03_handmade_06.txt AC 19 ms 7736 KiB
03_handmade_07.txt AC 19 ms 7820 KiB
03_handmade_08.txt AC 25 ms 7740 KiB