Submission #1007974

#TimeUsernameProblemLanguageResultExecution timeMemory
1007974LuvidiLasers (NOI19_lasers)C++17
100 / 100
94 ms32972 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll, ll> #define pii pair<int, int> #define fs first #define sc second #define pb push_back void solve() { int l,r; cin>>l>>r; vector<int> a[r]; for (int i=0;i<r;i++){ int x; cin>>x; while(x--){ int y; cin>>y; a[i].pb(y); } } vector<pii> seg; for (int i=0;i<r;i++){ int s=a[i].size(); int pre[s],suf[s]; pre[0]=a[i][0]; for (int j=1;j<s;j++)pre[j]=pre[j-1]+a[i][j]; suf[s-1]=a[i][s-1]; for (int j=s-2;j>=0;j--)suf[j]=suf[j+1]+a[i][j]; for (int j=0;j<s;j++){ int le=l-suf[j]+1, ri=pre[j]; if(le<=ri)seg.pb({le,ri}); } } sort(seg.begin(),seg.end()); int ans=0,le=0,ri=-1; for (int i=0;i<seg.size();i++){ if(seg[i].fs>ri){ ans+=ri-le+1; le=seg[i].fs; } ri=max(ri,seg[i].sc); } cout<<ans+ri-le+1; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); }

Compilation message (stderr)

lasers.cpp: In function 'void solve()':
lasers.cpp:39:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (int i=0;i<seg.size();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...