結果

問題 No.1 道のショートカット
ユーザー programvxprogramvx
提出日時 2018-12-20 17:48:54
言語 C++11
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 1,608 bytes
コンパイル時間 794 ms
コンパイル使用メモリ 71,592 KB
実行使用メモリ 10,144 KB
最終ジャッジ日時 2024-07-08 05:07:09
合計ジャッジ時間 7,322 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 4 TLE * 1 -- * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#define ll long long

using namespace std;

struct tga
{

    ll s;
    ll t;
    ll y;
    ll m;
};

int tagawaaaaa(ll pos);

ll countNum = 0;

ll V, C, N;

ll myTime;
ll myCost;
ll ansTime = -1;
vector<tga> vec(1);

int main()
{
    ll posi;

    cin >> N >> C >> V;

    posi = N;

    ll temochi = C;
    ll stime = 0;
    ll ans = 0;

    vec.resize(V);
    vector<ll> count(V);

    for (ll i = 0; i < V; i++)
    {
        cin >> vec[i].s;
    }
    for (ll i = 0; i < V; i++)
    {
        cin >> vec[i].t;
        count[i] = vec[i].t;
    }
    for (ll i = 0; i < V; i++)
    {
        cin >> vec[i].y;
    }
    for (ll i = 0; i < V; i++)
    {
        cin >> vec[i].m;
    }

    sort(vec.begin(),vec.end(),
    [](const tga& a,const tga& b) {return a.t< b.t;});

    tagawaaaaa(posi);

    printf("%lld\n", ansTime);

    return 0;
}

int tagawaaaaa(ll pos)
{
    if (pos == 1)
    {
        countNum++;
        if (myCost <= C)
        {
            if (ansTime == -1)
                ansTime = myTime;
            else
            {
                if (ansTime > myTime)
                    ansTime = myTime;
            }
        }
        return 0;
    }
    for (ll i = 0; vec[i].t<=pos; i++)
    {
        if (pos == vec[i].t)
        {
            if (pos == N)
            {
                myTime = 0;
                myCost = 0;
            }
            myTime += vec[i].m;
            myCost += vec[i].y;
            tagawaaaaa(vec[i].s);
        }
    }
    return 0;
}
0