제출 #233145

#제출 시각아이디문제언어결과실행 시간메모리
233145nicolaalexandraSemiexpress (JOI17_semiexpress)C++14
100 / 100
13 ms512 KiB
#include <bits/stdc++.h> #define DIM 2010 using namespace std; long long v[DIM],w[DIM]; long long n,m,k,a,b,c,t,i; int main (){ //ifstream cin ("date.in"); //ofstream cout ("date.out"); cin>>n>>m>>k>>a>>b>>c>>t; for (i=1;i<=m;i++) cin>>v[i]; k -= m; /// mai intai vad cat ma pot extinde din statia i mergand doar cu tren normal for (i=1;i<=m;i++){ long long timp = b * (v[i] - 1); /// timp + a * cnt <= t if (timp > t) /// inseamna ca nici macar aici nu pot ajunge w[i] = -1; else { if (i != m) w[i] = min ((t - timp) / a, v[i+1] - v[i] - 1); } } for (;k--;){ /// adaug un tren long longre doua statii, iau varianta care imi aduce cele mai multe statii long long maxi = 0; int poz = 0; for (i=1;i<m;i++){ if (w[i] == -1 || v[i+1] - v[i] - 1 == w[i]) continue; /// v[i] + w[i] + 1 -> aici pun statie pt semiexpress long long timp = b * (v[i] - 1) + c * (w[i] + 1); if (timp > t) /// degeaba pun continue; /// timp + a * cnt <= t long long cnt = min ((t - timp) / a + 1, v[i+1] - (v[i] + w[i]) - 1); if (cnt > maxi) maxi = cnt, poz = i; } w[poz] += maxi; } long long sol = 0; for (i=1;i<=m;i++) sol += w[i] + 1; cout<<sol - 1; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...