結果

問題 No.1 道のショートカット
ユーザー programvxprogramvx
提出日時 2018-12-22 00:09:57
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,418 bytes
コンパイル時間 635 ms
コンパイル使用メモリ 73,692 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-22 13:25:31
合計ジャッジ時間 2,188 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

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 main()
{

  ll countNum = 0;
  ll anstime=-1;
  ll V, C, N;
  cin >> N >> C >> V;
  vector<struct tga> vec(V);
    for (ll i = 0; i < V; i++)
    {
        cin >> vec[i].s;
    }
    for (ll i = 0; i < V; i++)
    {
        cin >> 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 struct tga& a,const struct tga& b) {return a.t< b.t;});

    vector<ll> st,cst,tst;
    st.push_back(N);
    vector<ll> havei;
    for(ll i=0;i<V;i++){
      if(st[st.size()-1]==vec[i].t){
        st.push_back(vec[i].s);
        cst.push_back(vec[i].m);
        tst.push_back(vec[i].t);
        havei.push_back(i);
        i=-1;
      }
      else if(st.size()-1==1){
        if(C>=accumulate(cst.begin(),cst.end(),0)){
          if(anstime==-1){
            anstime=accumulate(tst.begin(),cst.end(),0);
          }
          else if(anstime>accumulate(tst.begin(),cst.end(),0)){
            anstime=accumulate(tst.begin(),cst.end(),0);
          }
        }
        countNum++;
        st.pop_back();
        i=havei[havei.size()-1];
        havei.pop_back();
        cst.pop_back();
        tst.pop_back();
      }
      //end loop
      else if(i==V-1){
        if(st[st.size()-1]==N)
        break;
        st.pop_back();
        i=havei[havei.size()-1];
        havei.pop_back();
        cst.pop_back();
        tst.pop_back();
      }
    }
    anstime=0;
    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