# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238434 | Kastanda | Segway (COI19_segway) | C++11 | 304 ms | 1276 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Criminal
#include<bits/stdc++.h>
using namespace std;
const int N = 20004;
int n, m, A[N][3], dp[N], M[N], C[N], S[N], P[N], T[N];
int main()
{
scanf("%d", &n);
for (int i = 1; i <= n; i ++)
for (int w = 0; w < 3; w ++)
scanf("%d", &A[i][w]);
scanf("%d", &m);
for (int i = 1, a; i <= m; i ++)
scanf("%d", &a), M[a] = 1;
for (int j = 1; j <= 300; j ++)
{
for (int i = 1; i <= n; i ++)
{
if (!C[i])
S[i] = A[i][(j - 1) / 100];
else
C[i] --;
dp[i] += S[i];
}
if (!M[j])
continue;
iota(P + 1, P + n + 1, 1);
sort(P + 1, P + n + 1, [&](int i, int j){return (dp[i] < dp[j]);});
int l = 1;
for (int i = 1; i <= n; i ++)
{
while (l < i && dp[P[l]] < dp[P[i]])
l ++;
T[P[i]] = l - 1;
}
for (int i = 1; i <= n; i ++)
if (!C[i])
S[i] = 1, C[i] = T[i] % 20;
}
for (int i = 1; i <= n; i ++)
printf("%d\n", dp[i]);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |