# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
242476 |
2020-06-27T19:32:15 Z |
MatesV13 |
Segway (COI19_segway) |
C++11 |
|
14 ms |
768 KB |
#include <bits/stdc++.h>
using namespace std;
long long n, a[305], b[305], c[305];
long long m, x, seg[305], dp[305][305], poz[305], ubrz[305];
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]++;}
for (long long vrijeme=1; vrijeme<15005; vrijeme++){
for (int i=0; i<n; i++){
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 (poz[i]<300) {
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++) cout << dp[i][300] << endl;
return 0;
}
/*
2
1 2 3
4 5 6
0
3
5 5 5
6 2 10
10 9 2
2
100 199
5
2 2 2
6 6 6
8 8 8
9 9 9
10 10 10
2
297 298
5
2 2 2
6 6 6
8 8 8
9 9 9
10 10 10
0
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
14 ms |
768 KB |
Output is correct |
3 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
14 ms |
768 KB |
Output is correct |
3 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |