結果

提出番号 945
提出者 Pulmn
言語 C++
提出日時 2017-08-01 15:59:58
問題名 (44)玉ねぎの収穫をするkotamanegi
結果 WA
点数 0%

テストケース

テストケース 結果 得点 実行時間 メモリ使用量
1 WA 0% 2ms 7504KB
2 WA 0% 2ms 7680KB
3 WA 0% 12ms 0KB
4 WA 0% 3ms 11696KB
5 WA 0% 10ms 0KB
6 WA 0% 5ms 15920KB
7 WA 0% 7ms 0KB
8 WA 0% 18ms 0KB
9 WA 0% 3ms 8528KB
10 WA 0% 3ms 8528KB
11 WA 0% 3ms 8528KB
12 WA 0% 2ms 7984KB
13 WA 0% 18ms 0KB
14 WA 0% 2ms 7680KB
15 WA 0% 6ms 18032KB
16 WA 0% 2ms 8336KB
17 WA 0% 3ms 8528KB
18 WA 0% 3ms 8528KB
19 WA 0% 10ms 0KB
20 WA 0% 2ms 7424KB

ソースコード

#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int h,w,y,x,xl,xr,yl,yr;
vi a,b;

int main(){
	cin>>h>>w>>y>>x;
	a=vi(h);
	b=vi(w);
	for(int i=0;i<h;i++) cin>>a[i];
	for(int i=0;i<w;i++) cin>>b[i];
	cin>>xl>>xr>>yl>>yr;
	vvi dp(h+1,vi(w+1,inf));
	dp[1][1]=0;
	for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) if(i!=1||j!=1){
		if(i<xl||xr<i||j<yl||yr<j) dp[i][j]=min(dp[i-1][j]+b[j-1],dp[i][j-1]+a[i-1]);
	}
	if(dp[x][y]==inf) cout<<-1<<endl;
	else cout<<dp[x][y]<<endl;
}