Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <map>
- std::ifstream fin ("ambuscada.in");
- std::ofstream fout ("ambuscada.out");
- int64_t n,m,v,l,r,k,ans,prev,sum;
- std::map <int64_t,int64_t> Mars;
- int main ()
- {
- fin>>n>>m>>v;
- Mars[1]+=v,Mars[n+1]-=v;
- for(int64_t i=1;i<=m;++ i)
- fin>>l>>r>>k,Mars[l]-=k,Mars[r+1]+=k;
- for(auto it:Mars)
- {
- if(sum>0)
- ans+=it.first-prev-1;
- sum+=it.second,prev=it.first;
- if(sum>0)
- ++ans;
- }
- fout<<ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement