답안 #238434

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
238434 2020-06-11T09:10:13 Z Kastanda Segway (COI19_segway) C++11
100 / 100
304 ms 1276 KB
// 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

segway.cpp: In function 'int main()':
segway.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
segway.cpp:11:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &A[i][w]);
             ~~~~~^~~~~~~~~~~~~~~~
segway.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &m);
     ~~~~~^~~~~~~~~~
segway.cpp:14:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a), M[a] = 1;
         ~~~~~~~~~~~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 9 ms 568 KB Output is correct
5 Correct 21 ms 1272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 7 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 9 ms 568 KB Output is correct
5 Correct 21 ms 1272 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 7 ms 384 KB Output is correct
17 Correct 6 ms 436 KB Output is correct
18 Correct 34 ms 384 KB Output is correct
19 Correct 65 ms 760 KB Output is correct
20 Correct 26 ms 888 KB Output is correct
21 Correct 120 ms 1016 KB Output is correct
22 Correct 257 ms 1276 KB Output is correct
23 Correct 304 ms 1152 KB Output is correct