# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
519846 | Lam_lai_cuoc_doi | 금 캐기 (IZhO14_divide) | C++17 | 1062 ms | 3560 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
void read(T &x)
{
x = 0;
register int c;
while ((c = getchar()) && (c > '9' || c < '0'))
;
for (; c >= '0' && c <= '9'; c = getchar())
x = x * 10 + c - '0';
}
constexpr bool typetest = 0;
constexpr int N = 1e5 + 5;
int n;
struct miningcamp
{
int x;
ll g, e;
miningcamp(int x = 0, ll g = 0, ll e = 0) : x(x), g(g), e(e) {}
bool operator<(const miningcamp &a) const
{
return x < a.x;
}
} a[N];
void Read()
{
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> a[i].x >> a[i].g >> a[i].e;
}
void Solve()
{
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; ++i)
{
a[i].e += a[i - 1].e;
a[i].g += a[i - 1].g;
}
ll ans(0);
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= i; ++j)
if (a[i].e - a[j - 1].e >= a[i].x - a[j].x)
ans = max(ans, a[i].g - a[j - 1].g);
cout << ans;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if (fopen("tests.inp", "r"))
{
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
int t(1);
if (typetest)
cin >> t;
for (int _ = 1; _ <= t; ++_)
{
// cout << "Case " << _ << ": ";
Read();
Solve();
}
cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}
/*
*/
컴파일 시 표준 에러 (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... |