답안 #671416

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
671416 2022-12-13T04:31:18 Z ReLice 금 캐기 (IZhO14_divide) C++17
0 / 100
534 ms 197476 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());
    l=0;
    r=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);}
      |                                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 534 ms 197476 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 534 ms 197476 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 534 ms 197476 KB Output isn't correct
2 Halted 0 ms 0 KB -