Submission #941285

# Submission time Handle Problem Language Result Execution time Memory
941285 2024-03-08T12:39:03 Z sleepntsheep Lottery (CEOI18_lot) C
0 / 100
30 ms 65536 KB
#include<stdio.h>

#define N 10001
int n,l,q,a[N],c[101],cc,o[101];
short ans[100][N];
short dp[N*(N+1)/2];

int pos(int x,int y)
{
    return (y+1ll)*(y+2)/2+x;
}

int main()
{
    scanf("%d%d",&n,&l);
    for(int i=1;i<=n;++i)scanf("%d",a+i);
    for(int i=1;i<=n;++i)for(int j=i+1;j<=n;++j)dp[pos(i,j)]=(a[i]!=a[j]);
    for(int i=1;i<=n;++i)for(int j=i+1;j<=n;++j)dp[pos(i,j)]+=dp[pos(i-1,j-1)];

    scanf("%d",&q);
    for(int i=0;i<q;++i)
    {
        scanf("%d",c+i);
    }

    for(int i=1;i+l-1<=n;++i)for(int j=i+1;j+l-1<=n;++j)
    {
        int d=dp[pos(i+l-1,j+l-1)]-dp[pos(i-1,j-1)];
        for(int k=0;k<100;++k)
        {
            if(c[k]>=d)
            {
                ans[i][k]++;
                ans[j][k]++;
                break;
            }
        }
    }

    for(int i=1;i<=n;++i)for(int j=1;j<=n;++j)ans[i][j]+=ans[i][j-1];
    for(int u=0;u<q;++u)
    {
        for(int i=1;i+l-1<=n;++i)printf("%d ",ans[i][u]);
        puts("");
    }
}

Compilation message

lot.c: In function 'main':
lot.c:15:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d%d",&n,&l);
      |     ^~~~~~~~~~~~~~~~~~~
lot.c:16:26: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     for(int i=1;i<=n;++i)scanf("%d",a+i);
      |                          ^~~~~~~~~~~~~~~
lot.c:20:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     scanf("%d",&q);
      |     ^~~~~~~~~~~~~~
lot.c:23:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         scanf("%d",c+i);
      |         ^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 30 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -