# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
765573 | 2023-06-24T20:50:48 Z | HD1 | 금 캐기 (IZhO14_divide) | C++14 | 2 ms | 340 KB |
//we are all lost trying to be someone. #include <bits/stdc++.h> #define fastio ios_base::sync_with_stdio(0); cin.tie(0); #define sz(x) ll(x.size()) #define reve(x) reverse(x.begin(),x.end()) #define ff first #define ss second using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll,ll> ii; const ll MAX=1e5+10; const ll mod=1e9+7; const ll inf=1e18+7; vector<pair<ll,ii>>s; ll gold[MAX], energy[MAX]; void solve(){ ll n; cin>>n; for(ll i=0; i<n; i++){ ll x, g, e; cin>>x>>g>>e; s.push_back({x,{g,e}}); } sort(s.begin(),s.end()); for(ll i=1; i<=n; i++){ gold[i]=gold[i-1]+s[i-1].ss.ff; energy[i]=energy[i-1]+s[i-1].ss.ss; } ll ans=0; for(ll i=1; i<=n; i++){ for(ll j=i; j<=n; j++){ ll eg=energy[j]-energy[i-1]; ll go=gold[j]-gold[i-1]; ll distance=s[j-1].ff-s[i-1].ff; if(distance<=eg){ ans=max(ans, go); } } } cout<<ans<<endl; } int main(){ fastio; freopen("divide.in", "r", stdin); freopen("divide.out", "w", stdout); solve(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |