Advertisement
Slayerfeed

Tower summer o comp cmu

Mar 30th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int land[1010];
  6. int main(){
  7.     int n,m;
  8.     cin >> n >> m;
  9.     int a,b,x;
  10.     for(int i=0;i<m;++i){
  11.         int max1=-1e9;
  12.         cin >> a >> b >> x;
  13.         for(int i=a;i<=b;++i){
  14.             land[i]+=x;
  15.  
  16.         }
  17.         for(int i=1;i<=n;++i){
  18.             if(land[i]>max1){
  19.                 max1=land[i];
  20.             }
  21.         }
  22.         int cnt=0;
  23.         for(int i=1;i<=n;++i){
  24.             if(max1==0&&land[1]==0&&i==1){
  25.                  ++cnt;
  26.             }
  27.             if(land[i]==max1&&land[i]!=land[i-1]){
  28.                     ++cnt;
  29.             }
  30.         }
  31.         cout << max1 << " " <<  cnt << "\n";
  32.     }
  33.  
  34.  
  35.     return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement