답안 #555078

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
555078 2022-04-30T06:17:01 Z Koosha_mv Sightseeing in Kyoto (JOI22_kyoto) C++14
10 / 100
20 ms 8276 KB
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
#define int ll

const int N=1005,inf=1e17;

int n,m,ans,a[N],b[N],dp[N][N];

int solve(vector<int> A,vector<int> B){
	f(i,0,N) f(j,0,N) dp[i][j]=inf;
	dp[0][0]=0;
	int n=A.size(),m=B.size();
	f_(i,n-2,0) minm(A[i],A[i+1]);
	f_(i,m-2,0) minm(B[i],B[i+1]);
	f(i,0,n) f(j,0,m){
		minm(dp[i+1][j],dp[i][j]+B[j]);
		minm(dp[i][j+1],dp[i][j]+A[i]);
	}
	return dp[n-1][m-1];
}

int32_t main(){
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin>>n>>m;
	if(n>1000 || m>1000) assert(0);
	int ida=1,idb=1;
	f(i,1,n+1){
		cin>>a[i];
		if(a[i]<a[ida]) ida=i;
	}
	f(i,1,m+1){
		cin>>b[i];
		if(b[i]<b[idb]) idb=i;
	}
	vector<int> A,B;
	f_(i,ida,1) A.pb(a[i]);
	f_(i,idb,1) B.pb(b[i]);
	ans+=solve(A,B);
	A.clear();
	B.clear();
	f(i,ida,n+1) A.pb(a[i]);
	f(i,idb,m+1) B.pb(b[i]);
	ans+=solve(A,B);
	cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8148 KB Output is correct
2 Correct 6 ms 8148 KB Output is correct
3 Correct 7 ms 8148 KB Output is correct
4 Correct 5 ms 8148 KB Output is correct
5 Correct 5 ms 8148 KB Output is correct
6 Correct 5 ms 8148 KB Output is correct
7 Correct 7 ms 8148 KB Output is correct
8 Correct 5 ms 8148 KB Output is correct
9 Correct 7 ms 8276 KB Output is correct
10 Correct 9 ms 8276 KB Output is correct
11 Correct 20 ms 8224 KB Output is correct
12 Correct 6 ms 8276 KB Output is correct
13 Correct 6 ms 8272 KB Output is correct
14 Correct 6 ms 8148 KB Output is correct
15 Correct 6 ms 8276 KB Output is correct
16 Correct 7 ms 8212 KB Output is correct
17 Correct 10 ms 8276 KB Output is correct
18 Correct 5 ms 8148 KB Output is correct
19 Correct 5 ms 8148 KB Output is correct
20 Correct 5 ms 8140 KB Output is correct
21 Correct 5 ms 8148 KB Output is correct
22 Correct 5 ms 8224 KB Output is correct
23 Correct 5 ms 8148 KB Output is correct
24 Correct 4 ms 8148 KB Output is correct
25 Correct 4 ms 8148 KB Output is correct
26 Correct 5 ms 8148 KB Output is correct
27 Correct 7 ms 8124 KB Output is correct
28 Correct 4 ms 8148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8148 KB Output is correct
2 Correct 4 ms 8148 KB Output is correct
3 Runtime error 1 ms 468 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8148 KB Output is correct
2 Correct 6 ms 8148 KB Output is correct
3 Correct 7 ms 8148 KB Output is correct
4 Correct 5 ms 8148 KB Output is correct
5 Correct 5 ms 8148 KB Output is correct
6 Correct 5 ms 8148 KB Output is correct
7 Correct 7 ms 8148 KB Output is correct
8 Correct 5 ms 8148 KB Output is correct
9 Correct 7 ms 8276 KB Output is correct
10 Correct 9 ms 8276 KB Output is correct
11 Correct 20 ms 8224 KB Output is correct
12 Correct 6 ms 8276 KB Output is correct
13 Correct 6 ms 8272 KB Output is correct
14 Correct 6 ms 8148 KB Output is correct
15 Correct 6 ms 8276 KB Output is correct
16 Correct 7 ms 8212 KB Output is correct
17 Correct 10 ms 8276 KB Output is correct
18 Correct 5 ms 8148 KB Output is correct
19 Correct 5 ms 8148 KB Output is correct
20 Correct 5 ms 8140 KB Output is correct
21 Correct 5 ms 8148 KB Output is correct
22 Correct 5 ms 8224 KB Output is correct
23 Correct 5 ms 8148 KB Output is correct
24 Correct 4 ms 8148 KB Output is correct
25 Correct 4 ms 8148 KB Output is correct
26 Correct 5 ms 8148 KB Output is correct
27 Correct 7 ms 8124 KB Output is correct
28 Correct 4 ms 8148 KB Output is correct
29 Correct 4 ms 8148 KB Output is correct
30 Correct 4 ms 8148 KB Output is correct
31 Runtime error 1 ms 468 KB Execution killed with signal 6
32 Halted 0 ms 0 KB -