結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
programvx
|
| 提出日時 | 2018-12-22 00:09:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,418 bytes |
| コンパイル時間 | 712 ms |
| コンパイル使用メモリ | 71,968 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-08 05:06:54 |
| 合計ジャッジ時間 | 1,947 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 4 |
| other | WA * 40 |
ソースコード
#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;
}
*/
programvx