Submission #611627

# Submission time Handle Problem Language Result Execution time Memory
611627 2022-07-29T06:08:18 Z 박상훈(#8496) Segway (COI19_segway) C++17
100 / 100
93 ms 30100 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
struct State{
    int a[3];

    int curs(int pos){
        if (pos<100) return a[0];
        else if (pos<200) return a[1];
        return a[2];
    }
}a[20020];

int dp[303][20020], cnt[15015], S[15015];
bool no[303][20020], chk[303];

int main(){
    int n;
    scanf("%d", &n);
    for (int i=1;i<=n;i++) scanf("%d %d %d", &a[i].a[0], &a[i].a[1], &a[i].a[2]);

    int m;
    scanf("%d", &m);
    for (int i=1;i<=m;i++){
        int x;
        scanf("%d", &x);
        chk[x] = 1;
    }

    for (int i=1;i<=300;i++) fill(dp[i]+1, dp[i]+n+1, -1);

    for (int i=1;i<=300;i++){
        for (int j=1;j<=n;j++) if (dp[i][j]==-1) dp[i][j] = dp[i-1][j] + a[j].curs(i-1);
        if (!chk[i]) continue;

        fill(cnt, cnt+15015, 0);
        fill(S, S+15015, 0);
        for (int j=1;j<=n;j++) cnt[dp[i][j]]++;
        for (int j=1;j<15015;j++) S[j] = S[j-1] + cnt[j];

        for (int j=1;j<=n;j++) if (!no[i][j]){
            int x = (S[dp[i][j]-1]) % 20;
            x = min(x, 300-i);
            //printf("%d %d -> %d\n", i, j, x);

            for (int k=1;k<=x;k++){
                dp[i+k][j] = dp[i][j] + k;
                no[i+k][j] = 1;
            }
            no[i+x][j] = 0;
        }
    }

    for (int i=1;i<=n;i++) printf("%d\n", dp[300][i]);
    return 0;
}

Compilation message

segway.cpp: In function 'int main()':
segway.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
segway.cpp:21:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     for (int i=1;i<=n;i++) scanf("%d %d %d", &a[i].a[0], &a[i].a[1], &a[i].a[2]);
      |                            ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
segway.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     scanf("%d", &m);
      |     ~~~~~^~~~~~~~~~
segway.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1620 KB Output is correct
2 Correct 2 ms 1876 KB Output is correct
3 Correct 3 ms 2644 KB Output is correct
4 Correct 6 ms 5332 KB Output is correct
5 Correct 43 ms 24296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1876 KB Output is correct
2 Correct 1 ms 1748 KB Output is correct
3 Correct 11 ms 2772 KB Output is correct
4 Correct 17 ms 2772 KB Output is correct
5 Correct 2 ms 2004 KB Output is correct
6 Correct 13 ms 2896 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 3 ms 3028 KB Output is correct
9 Correct 6 ms 3156 KB Output is correct
10 Correct 4 ms 2956 KB Output is correct
11 Correct 15 ms 3176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1620 KB Output is correct
2 Correct 2 ms 1876 KB Output is correct
3 Correct 3 ms 2644 KB Output is correct
4 Correct 6 ms 5332 KB Output is correct
5 Correct 43 ms 24296 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
7 Correct 1 ms 1748 KB Output is correct
8 Correct 11 ms 2772 KB Output is correct
9 Correct 17 ms 2772 KB Output is correct
10 Correct 2 ms 2004 KB Output is correct
11 Correct 13 ms 2896 KB Output is correct
12 Correct 2 ms 2644 KB Output is correct
13 Correct 3 ms 3028 KB Output is correct
14 Correct 6 ms 3156 KB Output is correct
15 Correct 4 ms 2956 KB Output is correct
16 Correct 15 ms 3176 KB Output is correct
17 Correct 3 ms 3028 KB Output is correct
18 Correct 25 ms 5792 KB Output is correct
19 Correct 34 ms 15752 KB Output is correct
20 Correct 31 ms 17576 KB Output is correct
21 Correct 52 ms 25056 KB Output is correct
22 Correct 78 ms 30076 KB Output is correct
23 Correct 93 ms 30100 KB Output is correct