Submission #764856

# Submission time Handle Problem Language Result Execution time Memory
764856 2023-06-24T05:53:52 Z ymm Sightseeing in Kyoto (JOI22_kyoto) C++17
10 / 100
2000 ms 3452 KB
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#define MIN(x, y) ((x)<(y)?(x):(y))

const int S = 600;
const int N = 100'010+S;
typedef ll T;
T A[N], B[N], Ar[N];
int n, m;

T lft[N];
int pos;

void mov(int k)
{
	static T tmp[2][S];
	tmp[0][0] = lft[0] + A[0];
	Loop (i,1,k) {
		bool i2 = i&1, i1 = !(i&1);
		tmp[i2][0] = MIN(lft[i] + A[i], tmp[i1][0] + B[pos+1]);
		Loop (j,1,i) {
			tmp[i2][j] = MIN(tmp[i1][j-1] + Ar[n-i+j],
					tmp[i1][j] + B[pos+1+j]);
		}
		tmp[i2][i] = tmp[i1][i-1] + A[0];
	}
	lft[0] = tmp[(k-1)&1][k-1];
	Loop (i,k,n) {
		bool i2 = i&1, i1 = !(i&1);
		tmp[i2][0] = MIN(lft[i] + A[i], tmp[i1][0] + B[pos+1]);
		Loop (j,1,k) {
			tmp[i2][j] = MIN(tmp[i1][j-1] + Ar[n-i+j],
					tmp[i1][j] + B[pos+1+j]);
		}
		lft[i-k+1] = tmp[i2][k-1];
	}
	Loop (i,n,n+k-1) {
		bool i2 = i&1, i1 = !(i&1);
		Loop (j,i-n+1,k) {
			tmp[i2][j] = MIN(tmp[i1][j-1] + Ar[n-i+j],
					tmp[i1][j] + B[pos+1+j]);
		}
		lft[i-k+1] = tmp[i2][k-1];
	}
	pos += k;
}



int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	cin >> n >> m;
	Loop (i,0,n) {
		ll x;
		cin >> x;
		A[i] = x;
		Ar[n-i] = A[i];
	}
	Loop (i,0,m) {
		ll x;
		cin >> x;
		B[i] = x;
	}
	Loop (i,0,n)
		lft[i] = B[0]*i;
	while (pos < m-1)
		mov(MIN(S, MIN(n, m-1-pos)));
	cout << (ll)lft[n-1] << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 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 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 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 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 311 ms 2148 KB Output is correct
5 Correct 9 ms 852 KB Output is correct
6 Correct 2 ms 1108 KB Output is correct
7 Execution timed out 2076 ms 3452 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 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 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 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 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 311 ms 2148 KB Output is correct
33 Correct 9 ms 852 KB Output is correct
34 Correct 2 ms 1108 KB Output is correct
35 Execution timed out 2076 ms 3452 KB Time limit exceeded
36 Halted 0 ms 0 KB -