結果

問題 No.1 道のショートカット
ユーザー programvxprogramvx
提出日時 2018-12-22 01:18:30
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,548 bytes
コンパイル時間 627 ms
コンパイル使用メモリ 74,824 KB
実行使用メモリ 7,668 KB
最終ジャッジ日時 2023-09-22 13:26:29
合計ジャッジ時間 7,376 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#define ll long long
using namespace std;
typedef struct tga{
  int s,t,y,m;
} tga;
int main(){
  int N,C,V,numCount=0,ansTime=-1;
  cin>>N>>C>>V;
  vector<int> st,yst,mst,ist;
  vector<tga> v(V);
  for(int i=0;i<V;i++){
      cin>>v[i].s;
    }
  for(int i=0;i<V;i++){
      cin>>v[i].t;
    }
  for(int i=0;i<V;i++){
      cin>>v[i].y;
    }
  for(int i=0;i<V;i++){
      cin>>v[i].m;
    }
    sort(v.begin(),v.end(),
    [](const tga& a,const tga& b) {return a.t< b.t;});

    st.push_back(N);


    for(int i=0;;i++){
      if(st[st.size()-1]==v[i].t){
        st.push_back(v[i].s);
        ist.push_back(i);
        yst.push_back(v[i].y);
        mst.push_back(v[i].m);
        i=-1;
      }
      else if(st[st.size()-1]==1){
        if(C>=accumulate(yst.begin(),yst.end(),0)){
          if(ansTime==-1){
            ansTime=accumulate(mst.begin(),mst.end(),0);
          }
          else{
            if(ansTime>accumulate(mst.begin(),mst.end(),0))
            ansTime=accumulate(mst.begin(),mst.end(),0);
          }
        }
        numCount++;
        st.pop_back();
        i=ist[ist.size()-1];
        ist.pop_back();
        yst.pop_back();
        mst.pop_back();
      }
      else if(v[i].t>st[st.size()-1]){
        if(st[st.size()-1]==N)
        break;
        st.pop_back();
        i=ist[ist.size()-1];
        ist.pop_back();
        yst.pop_back();
        mst.pop_back();
      }
    }
printf("%d",ansTime);
}
0