Advertisement
a53

Ambuscada

a53
Jun 6th, 2020
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <fstream>
  2. #include <map>
  3. std::ifstream fin ("ambuscada.in");
  4. std::ofstream fout ("ambuscada.out");
  5. int64_t n,m,v,l,r,k,ans,prev,sum;
  6. std::map <int64_t,int64_t> Mars;
  7.  
  8. int main ()
  9. {
  10. fin>>n>>m>>v;
  11. Mars[1]+=v,Mars[n+1]-=v;
  12. for(int64_t i=1;i<=m;++ i)
  13. fin>>l>>r>>k,Mars[l]-=k,Mars[r+1]+=k;
  14. for(auto it:Mars)
  15. {
  16. if(sum>0)
  17. ans+=it.first-prev-1;
  18. sum+=it.second,prev=it.first;
  19. if(sum>0)
  20. ++ans;
  21. }
  22. fout<<ans;
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement