Submission #1007947

# Submission time Handle Problem Language Result Execution time Memory
1007947 2024-06-26T02:46:36 Z devariaota Lasers (NOI19_lasers) C++17
0 / 100
1000 ms 9592 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[1000005];
signed main()
{
  int n, q;
  scanf("%lld %lld", &n, &q);
  if(n<=1000000)
  {
    int ans=0;
    for(int i=1; i<=q; i++)
    {
      int k;
      scanf("%lld", &k);
      int l[k+5], pre[k+5];pre[0]=0;
      for(int j=1; j<=k; j++)
      {
        scanf("%lld", &l[j]);
        pre[j]=pre[j-1]+l[j];
      }
      if(pre[k]>n/2)
      {
        int gap=n-pre[k];
        for(int i=0; i<k; i++)
        {
          a[pre[i]+gap+1]++;
          a[pre[i+1]+1]--;
//          printf("%lld %lld\n", pre[i]+gap+1, pre[i+1]+1);
        }  
      }
    }
    for(int i=1; i<=n; i++)
    {
      a[i]+=a[i-1];
      if(a[i]<=0)
      {
//        printf("%lld\n", i);
        ans++;
      }
    }
    printf("%lld\n", n-ans);
  }
  else
  {
    int ans=0;
    scanf("%lld %lld", &n, &q);
    for(int i=1; i<=q; i++)
    {
      int k;
      scanf("%lld", &k);
      for(int j=1; j<=k; j++)
      {
        int p;
        scanf("%lld", &p);
        ans=max(ans, 2*p-n);
      }
    }
    printf("%lld\n", ans);
  }
}

Compilation message

lasers.cpp: In function 'int main()':
lasers.cpp:8:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |   scanf("%lld %lld", &n, &q);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~
lasers.cpp:15:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |       scanf("%lld", &k);
      |       ~~~~~^~~~~~~~~~~~
lasers.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         scanf("%lld", &l[j]);
      |         ~~~~~^~~~~~~~~~~~~~~
lasers.cpp:47:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |     scanf("%lld %lld", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
lasers.cpp:51:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |       scanf("%lld", &k);
      |       ~~~~~^~~~~~~~~~~~
lasers.cpp:55:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |         scanf("%lld", &p);
      |         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1035 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1035 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 9592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 9592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1035 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -