답안 #1007948

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1007948 2024-06-26T02:50:10 Z makanhulia Lasers (NOI19_lasers) C++17
63 / 100
1000 ms 12380 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];
      }
      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;
    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);
      |         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1041 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1041 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 9820 KB Output is correct
2 Correct 7 ms 8540 KB Output is correct
3 Correct 10 ms 8536 KB Output is correct
4 Correct 19 ms 10500 KB Output is correct
5 Correct 11 ms 10076 KB Output is correct
6 Correct 24 ms 12380 KB Output is correct
7 Correct 2 ms 6748 KB Output is correct
8 Correct 38 ms 10844 KB Output is correct
9 Correct 16 ms 9048 KB Output is correct
10 Correct 20 ms 10392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 9820 KB Output is correct
2 Correct 7 ms 8540 KB Output is correct
3 Correct 10 ms 8536 KB Output is correct
4 Correct 19 ms 10500 KB Output is correct
5 Correct 11 ms 10076 KB Output is correct
6 Correct 24 ms 12380 KB Output is correct
7 Correct 2 ms 6748 KB Output is correct
8 Correct 38 ms 10844 KB Output is correct
9 Correct 16 ms 9048 KB Output is correct
10 Correct 20 ms 10392 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 73 ms 7232 KB Output is correct
22 Correct 10 ms 7516 KB Output is correct
23 Correct 7 ms 8028 KB Output is correct
24 Correct 33 ms 8796 KB Output is correct
25 Correct 62 ms 7000 KB Output is correct
26 Correct 24 ms 7256 KB Output is correct
27 Correct 9 ms 7528 KB Output is correct
28 Correct 66 ms 7052 KB Output is correct
29 Correct 64 ms 7340 KB Output is correct
30 Correct 23 ms 8280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1041 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -