Submission #1007948

#TimeUsernameProblemLanguageResultExecution timeMemory
1007948makanhuliaLasers (NOI19_lasers)C++17
63 / 100
1041 ms12380 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; 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 (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: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 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...