# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1063128 | 2024-08-17T14:28:56 Z | PotatoTheWarriorFRTT | Bulldozer (JOI17_bulldozer) | C++14 | 1 ms | 400 KB |
#include <bits/stdc++.h> using namespace std; long long MOD = 1000000000+7; typedef long long ll; typedef pair<pair<ll, ll>, ll> Point; int log2(int x) { int ln = -1; while(x > 0) { ln++; x/=2; } return ln; } bool comp(Point p1, Point p2) { return p1.first.first < p2.first.first; } ll max_sub_sum(vector<ll> &vals) { ll S[vals.size()+1]; ll M[vals.size()+1]; S[0] = 0; M[0] = 0; for(int i=1;i<=vals.size();i++) { S[i] = S[i-1]+vals[i-1]; M[i] = min(M[i-1], S[i]); } ll ans = 0; for(int i=0;i<vals.size();i++) { ans = max(ans, S[i+1] - M[i+1]); } return ans; } void solve() { int n; cin >> n; vector<Point> points; for(int i=0;i<n;i++) { Point p; cin >> p.first.first >> p.first.second >> p.second; points.push_back(p); } sort(points.begin(), points.end(), comp); vector<ll> vals; for(int i=0;i<n;i++) { vals.push_back(0); ll X = points[i].first.first; while(points[i].first.first == X) { vals[vals.size()-1]+=points[i].second; i++; } i--; } cout << max_sub_sum(vals) << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); // int t; // cin >> t; // while (t--) solve(); char sdhfn; cin >> sdhfn; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 400 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 400 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Incorrect | 0 ms | 344 KB | Output isn't correct |
17 | Halted | 0 ms | 0 KB | - |