Submission #240573

#TimeUsernameProblemLanguageResultExecution timeMemory
240573arnold518Lasers (NOI19_lasers)C++14
100 / 100
532 ms29212 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 5e5; int N, MM, K, A[MAXN+10], S[MAXN+10]; map<int, int> M; int main() { int i, j; scanf("%d%d", &N, &MM); while(MM--) { scanf("%d", &K); int D=N; for(i=1; i<=K; i++) scanf("%d", &A[i]), S[i]=S[i-1]+A[i], D-=A[i]; S[K+1]=N; for(i=0; i<=K; i++) { int l=S[i]+D+1, r=S[i+1]; if(l<=r) M[l]++, M[r+1]--; } } int ans=0, sum=0; for(auto it=M.begin(); it!=M.end() && next(it)!=M.end(); it++) { sum+=it->second; if(sum!=0) ans+=(next(it)->first)-(it->first); } printf("%d\n", ans); }

Compilation message (stderr)

lasers.cpp: In function 'int main()':
lasers.cpp:15:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^
lasers.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &N, &MM);
  ~~~~~^~~~~~~~~~~~~~~~~
lasers.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &K);
   ~~~~~^~~~~~~~~~
lasers.cpp:22:59: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   for(i=1; i<=K; i++) scanf("%d", &A[i]), S[i]=S[i-1]+A[i], D-=A[i];
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
#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...