# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1167839 | SmuggingSpun | 금 캐기 (IZhO14_divide) | C++20 | 13 ms | 328 KiB |
#include<bits/stdc++.h>
#define taskname "A"
using namespace std;
typedef long long ll;
const int lim = 1e5 + 5;
template<class T>void maximize(T& a, T b){
if(a < b){
a = b;
}
}
struct Data{
int x, g, d;
bool operator <(const Data& other){
return this->x < other.x;
}
};
int n;
Data a[lim];
namespace sub12{
void solve(){
sort(a + 1, a + n + 1);
ll ans = 0;
for(int i = 1; i <= n; i++){
ll gold = 0, energy = 0;
for(int j = i; j <= n; j++){
gold += a[j].g;
if((energy += a[j].d) >= a[j].x - a[i].x){
maximize(ans, gold);
}
}
}
cout << ans;
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i].x >> a[i].g >> a[i].d;
}
if(n <= 5000){
sub12::solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |