Submission #1274772

#TimeUsernameProblemLanguageResultExecution timeMemory
1274772Gadir_2880Divide and conquer (IZhO14_divide)C++20
48 / 100
1095 ms1604 KiB
#include<bits/stdc++.h>
#define int long long
#define debug(n,m) cout<<"["<<#n<<"]->"<<n<<m
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;

const int N=3e5+5;
const int mod=1e9+7;
const int inf=(1ll<<63)-1;

int a[N],b[N],c[N];

void solve() {
  //#define tests
  int n;
  cin>>n;
  for (int i=1;i<=n;i++) {
    cin>>a[i]>>b[i]>>c[i];
  }
  int res=0;
  for (int i=1;i<=n;i++){
    int e=0,g=0;
    for (int j=i;j<=n;j++) {
      e+=c[j];
      g+=b[j];
      if (e>=a[j]-a[i]+1) res=max(res,g);
    }
  }
  cout<<res<<'\n';
}

int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);int t=1;
  #ifdef tests
  cin>>t;
  #endif
  while(t--)solve();
}



/*

*/

Compilation message (stderr)

divide.cpp:10:24: warning: integer overflow in expression of type 'long long int' results in '9223372036854775807' [-Woverflow]
   10 | const int inf=(1ll<<63)-1;
      |               ~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...