#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long int lld;
typedef pair<pair<lld,lld>,lld> piii;
int cmp(pair<pair<lld,lld>,pair<int,int> > x, pair<pair<lld,lld>,pair<int,int> > y){
if(x.first.first*y.first.second>x.first.second*y.first.first){
return true;
}return false;
}
int main(){
int n;
scanf("%d",&n);
piii arr[n];
for(int i=0;i<n;i++){
scanf("%lld %lld %lld",&arr[i].first.first,&arr[i].first.second,&arr[i].second);
}sort(arr,arr+n);
lld ans=0;
vector<pair<pair<lld,lld>,pair<int,int> > > array;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
pair<lld,lld> p1=pair<lld,lld>(arr[j].first.second-arr[i].first.second,arr[j].first.first-arr[i].first.first);
array.push_back(pair<pair<lld,lld>,pair<int,int> >(p1,pair<int,int>(i,j)));
}
}sort(array.begin(),array.end(),cmp);
/*for(int i=0;i<array.size();i++){
cout<<array[i].first.first<<" "<<array[i].first.second<<" "<<array[i].second.first<<" "<<array[i].second.second<<endl;
}*/
pair<int,int> changes[array.size()];
for(int i=0;i<array.size();i++){
changes[i].first=array[i].second.first;
changes[i].second=array[i].second.second;
}
int per[n];
for(int i=0;i<n;i++)per[i]=i;
for(int i=0;i<array.size();i++){
int x,y;
for(int j=0;j<n;j++){
if(per[j]==array[i].second.first)x=j;
if(per[j]==array[i].second.second)y=j;
}
swap(per[x],per[y]);
lld DP[n];
lld zero=0;
DP[0]=max(zero,arr[per[0]].second);
ans=max(ans,DP[0]);
for(int j=1;j<n;j++){
DP[j]=max(zero,DP[j-1]+arr[per[j]].second);
ans=max(ans,DP[j]);
}
}cout<<ans<<endl;
return 0;
}
Compilation message
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:34:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<array.size();i++){
~^~~~~~~~~~~~~
bulldozer.cpp:40:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<array.size();i++){
~^~~~~~~~~~~~~
bulldozer.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
~~~~~^~~~~~~~~
bulldozer.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld %lld",&arr[i].first.first,&arr[i].first.second,&arr[i].second);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bulldozer.cpp:41:7: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
int x,y;
^
bulldozer.cpp:41:9: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
int x,y;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
704 KB |
Output is correct |
2 |
Correct |
4 ms |
640 KB |
Output is correct |
3 |
Correct |
4 ms |
640 KB |
Output is correct |
4 |
Correct |
4 ms |
640 KB |
Output is correct |
5 |
Correct |
4 ms |
640 KB |
Output is correct |
6 |
Correct |
5 ms |
640 KB |
Output is correct |
7 |
Correct |
4 ms |
640 KB |
Output is correct |
8 |
Correct |
4 ms |
640 KB |
Output is correct |
9 |
Correct |
4 ms |
640 KB |
Output is correct |
10 |
Correct |
4 ms |
640 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
704 KB |
Output is correct |
2 |
Correct |
4 ms |
640 KB |
Output is correct |
3 |
Correct |
4 ms |
640 KB |
Output is correct |
4 |
Correct |
4 ms |
640 KB |
Output is correct |
5 |
Correct |
4 ms |
640 KB |
Output is correct |
6 |
Correct |
5 ms |
640 KB |
Output is correct |
7 |
Correct |
4 ms |
640 KB |
Output is correct |
8 |
Correct |
4 ms |
640 KB |
Output is correct |
9 |
Correct |
4 ms |
640 KB |
Output is correct |
10 |
Correct |
4 ms |
640 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
704 KB |
Output is correct |
2 |
Correct |
4 ms |
640 KB |
Output is correct |
3 |
Correct |
4 ms |
640 KB |
Output is correct |
4 |
Correct |
4 ms |
640 KB |
Output is correct |
5 |
Correct |
4 ms |
640 KB |
Output is correct |
6 |
Correct |
5 ms |
640 KB |
Output is correct |
7 |
Correct |
4 ms |
640 KB |
Output is correct |
8 |
Correct |
4 ms |
640 KB |
Output is correct |
9 |
Correct |
4 ms |
640 KB |
Output is correct |
10 |
Correct |
4 ms |
640 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |