Submission #765597

# Submission time Handle Problem Language Result Execution time Memory
765597 2023-06-24T21:47:21 Z LeaRouse Divide and conquer (IZhO14_divide) C++14
0 / 100
0 ms 340 KB
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define ff first
#define ss second
using namespace std;
const int MAX = 5e4+5;
ll A[MAX],B[MAX],C[MAX];
pair<int,int>dp[(1<<21)+5];
void go(){
    int n;  cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i]>>B[i]>>C[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ll sum=B[i];
        ll ener=C[i];
        for(int j=i+1;j<n;j++){
            if(ener+C[j]>=abs(A[i]-A[j])){
                ener+=C[j];
                sum+=B[j];
                ans=max(ans,sum);
            }
        }
    }
    cout<<ans<<endl;
}

int main(){
    fastio;
    go();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -