제출 #1007949

#제출 시각아이디문제언어결과실행 시간메모리
1007949andecaandeciLasers (NOI19_lasers)C++17
87 / 100
67 ms12372 KiB
#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];
      }
      int gap=n-pre[k];
      for(int i=0; i<k; i++)
      {
        if(pre[i]+gap+1<=pre[i+1]+1)
        {
          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;
    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);
  }
}

컴파일 시 표준 에러 (stderr) 메시지

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:50:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |       scanf("%lld", &k);
      |       ~~~~~^~~~~~~~~~~~
lasers.cpp:54:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         scanf("%lld", &p);
      |         ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...