# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1063403 | medmdg | Bulldozer (JOI17_bulldozer) | C++14 | 33 ms | 604 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<pair<ll, ll>, pair<ll, ll>> Point;
bool comp(Point p1, Point p2) {
return p1.second.second < p2.second.second;
}
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;
long long x, y, w;
cin >> p.first.first >> p.first.second >> p.second.first;
points.push_back(p);
}
if(n==1) {
cout << max(0LL, points[0].second.first) << endl;
return;
}
ll ans =0;
for(int i=0;i<n;i++) {
for(int j=i+1;j<n;j++) {
pair<ll, ll> dir = {points[i].first.first - points[j].first.first, points[i].first.second - points[j].first.second};
if(dir.first != 0 || dir.second != 0 ) {
for(int k=0;k<n;k++) {
points[k].second.second = dir.second * points[k].first.second - dir.first * points[k].first.first;
}
sort(points.begin(), points.end(), comp);
vector<ll> vals;
for(int k=0;k<n;k++) {
vals.push_back(0);
ll X = points[k].second.second;
while(points[k].second.second == X) {
vals[vals.size()-1]+=points[k].second.first;
k++;
}
k--;
}
ans = max(ans, max_sub_sum(vals));
}
}
}
if(ans==0){
ll t=0;
for(auto i:points)t+=i.second.first;
ans=max(ans,t);
}
cout << ans << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |