Submission #492998

# Submission time Handle Problem Language Result Execution time Memory
492998 2021-12-10T01:28:53 Z khangal Divide and conquer (IZhO14_divide) C++14
48 / 100
1000 ms 30284 KB
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef double db;
typedef vector<long long> vl;
typedef pair<long long, long long > pl;
const int N = 1e6 + 1;
#define po pop_back
#define pb push_back
#define mk make_pair
#define lw lower_bound
#define up upper_bound
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MAX 1e18 
#define MIN -1e18
#define per(i,a,b) for(ll i=b;i>=a;i--)
#define con continue
#define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628
// typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// template< typename T>
// using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n, m, ans, mid, mn, mx, cnt, sum, h1, h2, arr[3234567],arr1[1234567], sz, k, i, j, h, a, w, x, y, z,par[1234567];
bool used[1234567];
//ll dx[4]={-1,1,0,0},dy[4]={0,0,-1,1},c1[123][123];
//vector<ll> edge[1234567];
//ll jump[22][223456];
//ll lvl[1234567];
//ll bit[1234567];
//ll timer;
//ll st[1234567],endd[1234567];
//pl tr[1234567];
//ll dp[5005][5005];
ll power(ll base, ll val, ll mod) {
    ll res = 1;
    while (val) {
        if (val % 2 == 1) {
            res = res * base;
        }
        base = base * base;
        base %= mod;
        res %= mod;
        val /= 2;
    }
    return res;
}
bool comp(pl x,pl y){
    if(x.ff>y.ff)return true;
    return false;
}
ll find(ll x){
    if(x==par[x])return x;
    else return par[x]=find(par[x]);
}
class A {
public:
    static void funcA() {
        cin>>n;
        ll p[1234567],g[1234567],e[1234567];
        for(int i=1;i<=n;i++){
            ll pos,gold,energy;
            cin>>pos>>gold>>energy;
            p[i]=pos;
            g[i]=g[i-1]+gold;
            e[i]=e[i-1]+energy;
        }
        ll ans=0;
        ll mx=MIN;
        p[n+1]=MAX;
        p[0]=MIN;
        for(int i=1;i<=n;i++){
            for(int j=i;j<=n;j++){
                ll len = p[j]-p[i];
                //cout<<p[i]<<" "<<p[j]<<" "<<len<<'\n';
                if(len <= e[j]-e[i-1] && (p[j+1]-p[i]) > (e[j]-e[i-1]) && (p[j]-p[i-1]) > (e[j]-e[i-1])){
                    mx=max(mx,g[j]-g[i-1]);
                }
            }
        }
        cout<<mx<<'\n';
    }
}lol;
void solve() {
    A::funcA();
}
int main() {
    ll T = 1;
    //cin>>T;
    boost;
    while (T--) {
        solve();
    }
}

Compilation message

divide.cpp: In static member function 'static void A::funcA()':
divide.cpp:73:12: warning: unused variable 'ans' [-Wunused-variable]
   73 |         ll ans=0;
      |            ^~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 29260 KB Output is correct
2 Correct 12 ms 29260 KB Output is correct
3 Correct 12 ms 29252 KB Output is correct
4 Correct 12 ms 29260 KB Output is correct
5 Correct 12 ms 29260 KB Output is correct
6 Correct 12 ms 29260 KB Output is correct
7 Correct 13 ms 29292 KB Output is correct
8 Correct 12 ms 29284 KB Output is correct
9 Correct 12 ms 29280 KB Output is correct
10 Correct 12 ms 29228 KB Output is correct
11 Correct 12 ms 29260 KB Output is correct
12 Correct 12 ms 29284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 29260 KB Output is correct
2 Correct 12 ms 29260 KB Output is correct
3 Correct 12 ms 29252 KB Output is correct
4 Correct 12 ms 29260 KB Output is correct
5 Correct 12 ms 29260 KB Output is correct
6 Correct 12 ms 29260 KB Output is correct
7 Correct 13 ms 29292 KB Output is correct
8 Correct 12 ms 29284 KB Output is correct
9 Correct 12 ms 29280 KB Output is correct
10 Correct 12 ms 29228 KB Output is correct
11 Correct 12 ms 29260 KB Output is correct
12 Correct 12 ms 29284 KB Output is correct
13 Correct 12 ms 29260 KB Output is correct
14 Correct 11 ms 29200 KB Output is correct
15 Correct 12 ms 29260 KB Output is correct
16 Correct 12 ms 29300 KB Output is correct
17 Correct 12 ms 29260 KB Output is correct
18 Correct 13 ms 29260 KB Output is correct
19 Correct 12 ms 29260 KB Output is correct
20 Correct 13 ms 29260 KB Output is correct
21 Correct 13 ms 29260 KB Output is correct
22 Correct 14 ms 29260 KB Output is correct
23 Correct 26 ms 29392 KB Output is correct
24 Correct 24 ms 29400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 29260 KB Output is correct
2 Correct 12 ms 29260 KB Output is correct
3 Correct 12 ms 29252 KB Output is correct
4 Correct 12 ms 29260 KB Output is correct
5 Correct 12 ms 29260 KB Output is correct
6 Correct 12 ms 29260 KB Output is correct
7 Correct 13 ms 29292 KB Output is correct
8 Correct 12 ms 29284 KB Output is correct
9 Correct 12 ms 29280 KB Output is correct
10 Correct 12 ms 29228 KB Output is correct
11 Correct 12 ms 29260 KB Output is correct
12 Correct 12 ms 29284 KB Output is correct
13 Correct 12 ms 29260 KB Output is correct
14 Correct 11 ms 29200 KB Output is correct
15 Correct 12 ms 29260 KB Output is correct
16 Correct 12 ms 29300 KB Output is correct
17 Correct 12 ms 29260 KB Output is correct
18 Correct 13 ms 29260 KB Output is correct
19 Correct 12 ms 29260 KB Output is correct
20 Correct 13 ms 29260 KB Output is correct
21 Correct 13 ms 29260 KB Output is correct
22 Correct 14 ms 29260 KB Output is correct
23 Correct 26 ms 29392 KB Output is correct
24 Correct 24 ms 29400 KB Output is correct
25 Correct 26 ms 29344 KB Output is correct
26 Correct 69 ms 29296 KB Output is correct
27 Correct 71 ms 29464 KB Output is correct
28 Execution timed out 1090 ms 30284 KB Time limit exceeded
29 Halted 0 ms 0 KB -