Submission #242482

#TimeUsernameProblemLanguageResultExecution timeMemory
242482MatesV13Segway (COI19_segway)C++11
40 / 100
16 ms1152 KiB
#include <bits/stdc++.h> using namespace std; long long n, a[20005], b[20005], c[20005]; long long m, x, seg[305], dp[305][305], poz[305], ubrz[305]; long long ans[20005], nekoime[20005]; long long ubrzaj (int pozicija, int trenutak){ int ret=0; for (int i=0; i<n; i++) if (dp[i][pozicija] and dp[i][pozicija]<trenutak) ret++; return (ret%20); } int main (){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i=0; i<n; i++) cin >> a[i] >> b[i] >> c[i]; cin >> m; for (int i=0; i<m; i++){cin >> x; seg[x]++;} if (m!=1){ for (long long vrijeme=1; vrijeme<15005; vrijeme++){ for (int i=0; i<n; i++){ if (poz[i]>=300) continue; if (ubrz[i]){ dp[i][poz[i]+1] = dp[i][poz[i]]+1; ubrz[i]--; poz[i]++; if (!ubrz[i] and seg[poz[i]]) ubrz[i] = ubrzaj(poz[i], vrijeme); } else { if (poz[i]<100){ if (vrijeme - dp[i][poz[i]] == a[i]){ dp[i][poz[i]+1]=vrijeme; poz[i]++; if (!ubrz[i] and seg[poz[i]]) ubrz[i] = ubrzaj(poz[i], vrijeme); } } else if (poz[i]<200){ if (vrijeme - dp[i][poz[i]] == b[i]){ dp[i][poz[i]+1]=vrijeme; poz[i]++; if (!ubrz[i] and seg[poz[i]]) ubrz[i] = ubrzaj(poz[i], vrijeme); } } else { if (vrijeme - dp[i][poz[i]] == c[i]){ dp[i][poz[i]+1]=vrijeme; poz[i]++; if (!ubrz[i] and seg[poz[i]]) ubrz[i] = ubrzaj(poz[i], vrijeme); } } } } } for (int i=0; i<n; i++) ans[i] = dp[i][300]; } else { vector<pair<int, int> > time_person; for (int i=0; i<n; i++){ if (x<=100) { ans[i] = x*a[i]; time_person.push_back(make_pair(ans[i], i)); } else { ans[i]=a[i]*100; if (x<=200){ ans[i] += (x-100)*b[i]; time_person.push_back(make_pair(ans[i], i)); } else { ans[i]+=b[i]*100; ans[i] += (x-200)*c[i]; time_person.push_back(make_pair(ans[i], i)); } } } sort(time_person.begin(), time_person.end()); for (int i=0; i<n; i++){ if (i and time_person[i].first == time_person[i].second){ nekoime[i]=nekoime[i-1]; } else nekoime[i]=i; int idx = time_person[i].second; if (nekoime[i]+x>300) ans[idx] += (300-x); else { ans[idx]+=nekoime[i]; x+=nekoime[i]; cout << "idx: " << idx << " " << ans[idx] << " "; if (x<=100) ans[idx] += (100-x)*a[idx] + 100*b[idx] + 100*c[idx]; else if (x<=200) ans[idx] += (200-x)*b[idx] + 100*c[idx]; else ans[idx] += (300-x)*c[idx]; cout << ans[idx] << endl; x-=nekoime[i]; } } } for (int i=0; i<n; i++) cout << ans[i] << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...