Submission #642234

#TimeUsernameProblemLanguageResultExecution timeMemory
642234devariaotaLasers (NOI19_lasers)C++17
100 / 100
112 ms10016 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int l, r; cin >> l >> r; vector<pair<int, int>>seg; for(int i = 1; i <= r; i++){ int left = 0, right = l; int x; cin >> x; vector<int>v(x); for(int j = 0; j < x; j++){ cin >> v[j]; left += v[j]; } left -= v.back(); for(int j = x - 1; j >= 0; j--){ int l1 = left, r1 = left + v[j]; int l2 = right - v[j], r2 = right; if(max(l1, l2) < min(r1, r2)){ seg.emplace_back(max(l1, l2), min(r1, r2)); } if(j) left -= v[j - 1]; right -= v[j]; } } sort(seg.begin(), seg.end()); int ans = 0; int left = -1, right = -1; for(int i = 0; i < seg.size(); i++){ if(right < seg[i].first){ ans += (right - left); left = seg[i].first; } right = max(right, seg[i].second); } ans += (right - left); cout << ans << '\n'; return 0; }

Compilation message (stderr)

lasers.cpp: In function 'int main()':
lasers.cpp:36:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     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...