AtCoder Beginner Contest 013

Submission #1679670

Source codeソースコード

#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

ll n,h,a,b,c,d,e;

map<pair<int,int>,ll> ma;

ll dfs(ll nn, ll hh){
    ll ans = linf;

    if((int)ma.count(make_pair((int)nn,(int)hh)) > 0){
        ret ma[make_pair((int)nn,(int)hh)];
    }
    if(nn >= n)ret 0;
    
    if(hh - e > 0){
        ans = dfs(nn+1,hh - e);
    }else{
        ans = min(dfs(nn+1,hh+b)+a,dfs(nn+1,hh+d)+c);
    }
    //P(ans);
    ma[make_pair((int)nn,(int)hh)] =ans;
    ret ans;
}


int main(){
	
	cin >> n >> h >> a >> b >> c >> d >> e;
    	
    P(dfs(0,h));
	
	return  0;
}

Submission

Task問題 C - 節制
User nameユーザ名 hm05
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 TLE
Score得点 100
Source lengthソースコード長 2475 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Subtask1 10 / 10 sample_1.txt,sample_2.txt,sample_3.txt,01_010.txt,01_011.txt,01_020.txt,01_021.txt,01_100.txt,01_101.txt,01_110.txt,01_111.txt,01_200.txt,01_201.txt,01_220.txt,01_221.txt,01_random01.txt,01_random02.txt,01_random03.txt,01_random04.txt,01_random05.txt,01_random06.txt,01_random07.txt,01_random08.txt,01_random09.txt,01_random10.txt
Subtask2 30 / 30 sample_1.txt,sample_2.txt,sample_3.txt,02_010.txt,02_011.txt,02_020.txt,02_021.txt,02_100.txt,02_101.txt,02_110.txt,02_111.txt,02_200.txt,02_201.txt,02_220.txt,02_221.txt,02_random01.txt,02_random02.txt,02_random03.txt,02_random04.txt,02_random05.txt,02_random06.txt,02_random07.txt,02_random08.txt,02_random09.txt,02_random10.txt
Subtask3 60 / 60 sample_1.txt,sample_2.txt,sample_3.txt,sample_4.txt,01_010.txt,01_011.txt,01_020.txt,01_021.txt,01_100.txt,01_101.txt,01_110.txt,01_111.txt,01_200.txt,01_201.txt,01_220.txt,01_221.txt,01_random01.txt,01_random02.txt,01_random03.txt,01_random04.txt,01_random05.txt,01_random06.txt,01_random07.txt,01_random08.txt,01_random09.txt,01_random10.txt,02_010.txt,02_011.txt,02_020.txt,02_021.txt,02_100.txt,02_101.txt,02_110.txt,02_111.txt,02_200.txt,02_201.txt,02_220.txt,02_221.txt,02_random01.txt,02_random02.txt,02_random03.txt,02_random04.txt,02_random05.txt,02_random06.txt,02_random07.txt,02_random08.txt,02_random09.txt,02_random10.txt,03_010.txt,03_011.txt,03_012.txt,03_020.txt,03_021.txt,03_022.txt,03_100.txt,03_101.txt,03_102.txt,03_110.txt,03_111.txt,03_112.txt,03_200.txt,03_201.txt,03_202.txt,03_220.txt,03_221.txt,03_222.txt,03_random01.txt,03_random02.txt,03_random03.txt,03_random04.txt,03_random05.txt,03_random06.txt,03_random07.txt,03_random08.txt,03_random09.txt,03_random10.txt,03_random11.txt,03_random12.txt,03_random13.txt,03_random14.txt,03_random15.txt,03_random16.txt,03_random17.txt,03_random18.txt,03_random19.txt,03_random20.txt
Subtask4 0 / 1 01_010.txt,01_011.txt,01_020.txt,01_021.txt,01_100.txt,01_101.txt,01_110.txt,01_111.txt,01_200.txt,01_201.txt,01_220.txt,01_221.txt,01_random01.txt,01_random02.txt,01_random03.txt,01_random04.txt,01_random05.txt,01_random06.txt,01_random07.txt,01_random08.txt,01_random09.txt,01_random10.txt,02_010.txt,02_011.txt,02_020.txt,02_021.txt,02_100.txt,02_101.txt,02_110.txt,02_111.txt,02_200.txt,02_201.txt,02_220.txt,02_221.txt,02_random01.txt,02_random02.txt,02_random03.txt,02_random04.txt,02_random05.txt,02_random06.txt,02_random07.txt,02_random08.txt,02_random09.txt,02_random10.txt,03_010.txt,03_011.txt,03_012.txt,03_020.txt,03_021.txt,03_022.txt,03_100.txt,03_101.txt,03_102.txt,03_110.txt,03_111.txt,03_112.txt,03_200.txt,03_201.txt,03_202.txt,03_220.txt,03_221.txt,03_222.txt,03_random01.txt,03_random02.txt,03_random03.txt,03_random04.txt,03_random05.txt,03_random06.txt,03_random07.txt,03_random08.txt,03_random09.txt,03_random10.txt,03_random11.txt,03_random12.txt,03_random13.txt,03_random14.txt,03_random15.txt,03_random16.txt,03_random17.txt,03_random18.txt,03_random19.txt,03_random20.txt,04_010.txt,04_011.txt,04_020.txt,04_021.txt,04_100.txt,04_101.txt,04_110.txt,04_111.txt,04_200.txt,04_201.txt,04_220.txt,04_221.txt,04_random01.txt,04_random02.txt,04_random03.txt,04_random04.txt,04_random05.txt,sample_1.txt,sample_2.txt,sample_3.txt,sample_4.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01_010.txt AC 1 ms 256 KB
01_011.txt AC 1 ms 256 KB
01_020.txt AC 1 ms 256 KB
01_021.txt AC 1 ms 256 KB
01_100.txt AC 1 ms 256 KB
01_101.txt AC 1 ms 256 KB
01_110.txt AC 1 ms 256 KB
01_111.txt AC 1 ms 256 KB
01_200.txt AC 2 ms 256 KB
01_201.txt AC 1 ms 256 KB
01_220.txt AC 1 ms 256 KB
01_221.txt AC 1 ms 256 KB
01_random01.txt AC 1 ms 256 KB
01_random02.txt AC 1 ms 256 KB
01_random03.txt AC 1 ms 256 KB
01_random04.txt AC 1 ms 256 KB
01_random05.txt AC 1 ms 256 KB
01_random06.txt AC 1 ms 256 KB
01_random07.txt AC 1 ms 256 KB
01_random08.txt AC 1 ms 256 KB
01_random09.txt AC 1 ms 256 KB
01_random10.txt AC 1 ms 256 KB
02_010.txt AC 2 ms 256 KB
02_011.txt AC 2 ms 256 KB
02_020.txt AC 1 ms 256 KB
02_021.txt AC 2 ms 256 KB
02_100.txt AC 2 ms 256 KB
02_101.txt AC 1 ms 256 KB
02_110.txt AC 1 ms 256 KB
02_111.txt AC 2 ms 256 KB
02_200.txt AC 2 ms 256 KB
02_201.txt AC 1 ms 256 KB
02_220.txt AC 1 ms 256 KB
02_221.txt AC 1 ms 256 KB
02_random01.txt AC 1 ms 256 KB
02_random02.txt AC 1 ms 256 KB
02_random03.txt AC 1 ms 256 KB
02_random04.txt AC 1 ms 256 KB
02_random05.txt AC 1 ms 256 KB
02_random06.txt AC 1 ms 256 KB
02_random07.txt AC 1 ms 256 KB
02_random08.txt AC 1 ms 256 KB
02_random09.txt AC 1 ms 256 KB
02_random10.txt AC 1 ms 256 KB
03_010.txt AC 147 ms 16128 KB
03_011.txt AC 2 ms 384 KB
03_012.txt AC 82 ms 11520 KB
03_020.txt AC 4 ms 768 KB
03_021.txt AC 208 ms 18048 KB
03_022.txt AC 3 ms 640 KB
03_100.txt AC 69 ms 8704 KB
03_101.txt AC 3 ms 512 KB
03_102.txt AC 131 ms 14592 KB
03_110.txt AC 57 ms 8192 KB
03_111.txt AC 63 ms 8320 KB
03_112.txt AC 88 ms 10880 KB
03_200.txt AC 29 ms 4352 KB
03_201.txt AC 149 ms 16128 KB
03_202.txt AC 38 ms 4992 KB
03_220.txt AC 34 ms 3968 KB
03_221.txt AC 98 ms 12032 KB
03_222.txt AC 25 ms 3328 KB
03_random01.txt AC 30 ms 4480 KB
03_random02.txt AC 1 ms 256 KB
03_random03.txt AC 23 ms 4096 KB
03_random04.txt AC 188 ms 17920 KB
03_random05.txt AC 1 ms 256 KB
03_random06.txt AC 21 ms 3328 KB
03_random07.txt AC 3 ms 512 KB
03_random08.txt AC 232 ms 17920 KB
03_random09.txt AC 126 ms 15744 KB
03_random10.txt AC 1 ms 256 KB
03_random11.txt AC 52 ms 8064 KB
03_random12.txt AC 396 ms 27520 KB
03_random13.txt AC 84 ms 10368 KB
03_random14.txt AC 91 ms 11392 KB
03_random15.txt AC 1 ms 256 KB
03_random16.txt AC 193 ms 21120 KB
03_random17.txt AC 252 ms 23296 KB
03_random18.txt AC 2 ms 384 KB
03_random19.txt AC 8 ms 1280 KB
03_random20.txt AC 1 ms 256 KB
04_010.txt TLE
04_011.txt TLE
04_020.txt TLE
04_021.txt TLE
04_100.txt TLE
04_101.txt TLE
04_110.txt TLE
04_111.txt TLE
04_200.txt TLE
04_201.txt AC 55 ms 9472 KB
04_220.txt TLE
04_221.txt TLE
04_random01.txt TLE
04_random02.txt TLE
04_random03.txt TLE
04_random04.txt TLE
04_random05.txt TLE
sample_1.txt AC 1 ms 256 KB
sample_2.txt AC 1 ms 256 KB
sample_3.txt AC 1 ms 256 KB
sample_4.txt AC 97 ms 11520 KB