結果

問題 No.1 道のショートカット
ユーザー programvxprogramvx
提出日時 2018-12-22 14:41:48
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,047 bytes
コンパイル時間 785 ms
コンパイル使用メモリ 76,512 KB
実行使用メモリ 7,676 KB
最終ジャッジ日時 2023-09-22 13:27:42
合計ジャッジ時間 13,101 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 TLE -
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 10 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 TLE -
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{
  ll s,t,y,m;
} tga;
int main(){
  ll N,C,V,numCount=0,ansTime=-1;
  cin>>N>>C>>V;
  vector<ll> st,yst,mst,ist;
  vector<tga> v(V);
  vector<ll> goty(V+1,0),gotm(V+1,0);

  for(ll i=0;i<V;i++){
      cin>>v[i].s;
    }
  for(ll i=0;i<V;i++){
      cin>>v[i].t;
    }
  for(ll i=0;i<V;i++){
      cin>>v[i].y;
    }
  for(ll 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(ll i=0;;i++){
      if(st[st.size()-1]==v[i].t){
        yst.push_back(v[i].y);
        mst.push_back(v[i].m);
        if(C<=accumulate(yst.begin(),yst.end(),0)){
          yst.pop_back();
          mst.pop_back();
          continue;
        }
        if(goty[i]!=0&&gotm[i]!=0&&
        accumulate(mst.begin(),mst.end(),0)>gotm[i]&&
        accumulate(yst.begin(),yst.end(),0)>goty[i]){
          yst.pop_back();
          mst.pop_back();
          continue;
        }
        gotm[i]=accumulate(mst.begin(),mst.end(),0);
        goty[i]=accumulate(yst.begin(),yst.end(),0);
        st.push_back(v[i].s);
        ist.push_back(i);
        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("%lld",ansTime);
}
0