답안 #240281

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
240281 2020-06-19T06:25:55 Z rzh Bulldozer (JOI17_bulldozer) C++17
0 / 100
5 ms 512 KB
#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;
		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;
	}	
}

Compilation message

bulldozer.cpp: In function 'int main()':
bulldozer.cpp:32:6: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   ll ans;
      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Incorrect 5 ms 384 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 512 KB Output is correct
11 Incorrect 5 ms 384 KB Output isn't correct
12 Halted 0 ms 0 KB -