Submission #706552

# Submission time Handle Problem Language Result Execution time Memory
706552 2023-03-07T02:41:27 Z becaido Sightseeing in Kyoto (JOI22_kyoto) C++17
10 / 100
2000 ms 1096 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include <bits/stdc++.h>
using namespace std;

#ifdef WAIMAI
#define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE)
void dout() {cout << '\n';}
template<typename T, typename...U>
void dout(T t, U...u) {cout << t << (sizeof...(u) ? ", " : ""), dout(u...);}
#else
#define debug(...) 7122
#endif

#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second

const ll INF = 1e18;
const int SIZE = 1e5 + 5;

int n, m;
int a[SIZE], b[SIZE];
ll dp[2][SIZE];

void solve() {
    cin >> n >> m;
    FOR (i, 1, n) cin >> a[i];
    FOR (i, 1, m) cin >> b[i];
    FOR (i, 1, n) FOR (j, 1, m) {
        dp[i & 1][j] = INF;
        if (i == 1 && j == 1) {
            dp[i & 1][j] = 0;
            continue;
        }
        if (i > 1) dp[i & 1][j] = min(dp[i & 1][j], dp[!(i & 1)][j] + b[j]);
        if (j > 1) dp[i & 1][j] = min(dp[i & 1][j], dp[i & 1][j - 1] + a[i]);
    }
    cout << dp[n & 1][m] << '\n';
}

int main() {
    Waimai;
    solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 4 ms 340 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 4 ms 340 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 4 ms 340 KB Output is correct
14 Correct 4 ms 340 KB Output is correct
15 Correct 4 ms 340 KB Output is correct
16 Correct 5 ms 340 KB Output is correct
17 Correct 4 ms 364 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Execution timed out 2029 ms 1096 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 4 ms 340 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 4 ms 340 KB Output is correct
12 Correct 4 ms 340 KB Output is correct
13 Correct 4 ms 340 KB Output is correct
14 Correct 4 ms 340 KB Output is correct
15 Correct 4 ms 340 KB Output is correct
16 Correct 5 ms 340 KB Output is correct
17 Correct 4 ms 364 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Execution timed out 2029 ms 1096 KB Time limit exceeded
33 Halted 0 ms 0 KB -