이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll T = 1;
//cin >> T;
while (T--){
ll n;
cin >> n;
vector<pair<ll,ll>> a;
vector<ll> b;
for (int i = 0; i<n; i++){
ll x,y,w;
cin >> x >> y >> w;
a.push_back({x,w});
}
sort(a.begin(),a.end());
b.push_back(0);
for (int i = 0; i<n; i++){
b.push_back(a[i].second);
}
for (int i = 1; i<n+1; i++){
b[i] = b[i] + b[i-1];
}
ll cur_min = 0;
ll ans = 0;
for (int i = 0; i<n+1; i++){
if (b[i] < cur_min) cur_min = b[i];
ans = max(ans, b[i] - cur_min);
}
cout << ans << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |