Submission #671418

# Submission time Handle Problem Language Result Execution time Memory
671418 2022-12-13T04:37:27 Z ReLice Divide and conquer (IZhO14_divide) C++17
0 / 100
1000 ms 197428 KB
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define ld long double
#define pb push_back
#define sz size()
#define fr first
#define sc second
#define F for(int i=0;i<n;i++){}
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const ll mod=998244353;
const ll N=1e3+10;
void solve(){
    ll n,m,k,i,j,l,r,i1,b,h,w,c=0,sum=0,ans=0,mx=-1;
    cin>>n;
    vector <pair<ll,pair<ll,ll>>> v;
    for(i=0;i<n;i++){
        cin>>i1>>l>>r;
        v.pb({i1,{l,r}});
    }
    sort(v.begin(),v.end());
    for(i=0;i<n;i++){
        l=i;
        r=i;
        ans=0;
        sum=0;
        while(r<n){
            ans+=v[r].sc.fr;
            sum+=v[r].sc.sc;
            while(v[r].fr-v[l].fr>sum){
                sum-=v[l].sc.sc;
                ans-=v[l].sc.fr;
                l++;
            }
            mx=max(mx,ans);
            r++;
        }
    }
    cout<<mx<<endl;
}
signed main(){
    fre("divide");
    start();
    ll t=1;
    //cin>>t;
    while(t--) solve();
}

Compilation message

divide.cpp: In function 'void solve()':
divide.cpp:21:10: warning: unused variable 'm' [-Wunused-variable]
   21 |     ll n,m,k,i,j,l,r,i1,b,h,w,c=0,sum=0,ans=0,mx=-1;
      |          ^
divide.cpp:21:12: warning: unused variable 'k' [-Wunused-variable]
   21 |     ll n,m,k,i,j,l,r,i1,b,h,w,c=0,sum=0,ans=0,mx=-1;
      |            ^
divide.cpp:21:16: warning: unused variable 'j' [-Wunused-variable]
   21 |     ll n,m,k,i,j,l,r,i1,b,h,w,c=0,sum=0,ans=0,mx=-1;
      |                ^
divide.cpp:21:25: warning: unused variable 'b' [-Wunused-variable]
   21 |     ll n,m,k,i,j,l,r,i1,b,h,w,c=0,sum=0,ans=0,mx=-1;
      |                         ^
divide.cpp:21:27: warning: unused variable 'h' [-Wunused-variable]
   21 |     ll n,m,k,i,j,l,r,i1,b,h,w,c=0,sum=0,ans=0,mx=-1;
      |                           ^
divide.cpp:21:29: warning: unused variable 'w' [-Wunused-variable]
   21 |     ll n,m,k,i,j,l,r,i1,b,h,w,c=0,sum=0,ans=0,mx=-1;
      |                             ^
divide.cpp:21:31: warning: unused variable 'c' [-Wunused-variable]
   21 |     ll n,m,k,i,j,l,r,i1,b,h,w,c=0,sum=0,ans=0,mx=-1;
      |                               ^
divide.cpp: In function 'void fre(std::string)':
divide.cpp:12:27: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
divide.cpp:12:64: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 197428 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 197428 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 197428 KB Time limit exceeded
2 Halted 0 ms 0 KB -