#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const db eps = 1e-9;
int main(void) {
map < int , ll > ox;
int n;
ll answer = 0;
cin>>n;
vector < pii > p(n);
vi cost(n);
int index = -1;
for (auto & it : p) {
++index;
cin>>it.fi>>it.se>>cost[index];
ox[it.fi] += cost[index];
}
ll cnt = 0,sum = 0;
for (auto it : ox) {
sum += it.se;
smax(answer,sum - cnt);
smin(cnt,sum);
}
vector < db > M;
for (int ind = 0;ind < n;++ind)
for (int i = ind + 1;i < n;++i)
if (p[i].fi != p[ind].fi)
M.pb(1.0 * (p[i].se - p[ind].se) / (p[i].fi - p[ind].fi));
random_shuffle(all(M));
for (auto m : M) {
vector < pair < db , int > > v;
for (int i = 0;i < n;++i)
v.pb(mp(p[i].se - m * p[i].fi,cost[i]));
ll cnt = 0,sum = 0;
sort(all(v));
for (int i = 0,j = 0;i < n;i = j) {
j = i;
while (j < n && abs(v[i].fi - v[j].fi) < eps)
sum += v[j].se,++j;
smax(answer,sum - cnt);
smin(cnt,sum);
}
if (clock() > 1.96 * CLOCKS_PER_SEC)
break;
}
cout << answer << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
564 KB |
Output is correct |
2 |
Correct |
30 ms |
512 KB |
Output is correct |
3 |
Correct |
29 ms |
512 KB |
Output is correct |
4 |
Correct |
28 ms |
564 KB |
Output is correct |
5 |
Correct |
29 ms |
512 KB |
Output is correct |
6 |
Correct |
28 ms |
512 KB |
Output is correct |
7 |
Correct |
29 ms |
512 KB |
Output is correct |
8 |
Correct |
29 ms |
512 KB |
Output is correct |
9 |
Correct |
30 ms |
512 KB |
Output is correct |
10 |
Correct |
28 ms |
512 KB |
Output is correct |
11 |
Correct |
1 ms |
256 KB |
Output is correct |
12 |
Correct |
0 ms |
256 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
1 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
536 KB |
Output is correct |
2 |
Correct |
41 ms |
512 KB |
Output is correct |
3 |
Correct |
41 ms |
512 KB |
Output is correct |
4 |
Correct |
41 ms |
512 KB |
Output is correct |
5 |
Correct |
41 ms |
512 KB |
Output is correct |
6 |
Correct |
40 ms |
512 KB |
Output is correct |
7 |
Correct |
42 ms |
512 KB |
Output is correct |
8 |
Correct |
41 ms |
512 KB |
Output is correct |
9 |
Correct |
40 ms |
512 KB |
Output is correct |
10 |
Correct |
41 ms |
512 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
256 KB |
Output is correct |
13 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
536 KB |
Output is correct |
2 |
Correct |
41 ms |
512 KB |
Output is correct |
3 |
Correct |
41 ms |
512 KB |
Output is correct |
4 |
Correct |
41 ms |
512 KB |
Output is correct |
5 |
Correct |
41 ms |
512 KB |
Output is correct |
6 |
Correct |
40 ms |
512 KB |
Output is correct |
7 |
Correct |
42 ms |
512 KB |
Output is correct |
8 |
Correct |
41 ms |
512 KB |
Output is correct |
9 |
Correct |
40 ms |
512 KB |
Output is correct |
10 |
Correct |
41 ms |
512 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
256 KB |
Output is correct |
13 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
536 KB |
Output is correct |
2 |
Correct |
41 ms |
512 KB |
Output is correct |
3 |
Correct |
41 ms |
512 KB |
Output is correct |
4 |
Correct |
41 ms |
512 KB |
Output is correct |
5 |
Correct |
41 ms |
512 KB |
Output is correct |
6 |
Correct |
40 ms |
512 KB |
Output is correct |
7 |
Correct |
42 ms |
512 KB |
Output is correct |
8 |
Correct |
41 ms |
512 KB |
Output is correct |
9 |
Correct |
40 ms |
512 KB |
Output is correct |
10 |
Correct |
41 ms |
512 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
256 KB |
Output is correct |
13 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
564 KB |
Output is correct |
2 |
Correct |
30 ms |
512 KB |
Output is correct |
3 |
Correct |
29 ms |
512 KB |
Output is correct |
4 |
Correct |
28 ms |
564 KB |
Output is correct |
5 |
Correct |
29 ms |
512 KB |
Output is correct |
6 |
Correct |
28 ms |
512 KB |
Output is correct |
7 |
Correct |
29 ms |
512 KB |
Output is correct |
8 |
Correct |
29 ms |
512 KB |
Output is correct |
9 |
Correct |
30 ms |
512 KB |
Output is correct |
10 |
Correct |
28 ms |
512 KB |
Output is correct |
11 |
Correct |
1 ms |
256 KB |
Output is correct |
12 |
Correct |
0 ms |
256 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
1 ms |
256 KB |
Output is correct |
16 |
Correct |
41 ms |
536 KB |
Output is correct |
17 |
Correct |
41 ms |
512 KB |
Output is correct |
18 |
Correct |
41 ms |
512 KB |
Output is correct |
19 |
Correct |
41 ms |
512 KB |
Output is correct |
20 |
Correct |
41 ms |
512 KB |
Output is correct |
21 |
Correct |
40 ms |
512 KB |
Output is correct |
22 |
Correct |
42 ms |
512 KB |
Output is correct |
23 |
Correct |
41 ms |
512 KB |
Output is correct |
24 |
Correct |
40 ms |
512 KB |
Output is correct |
25 |
Correct |
41 ms |
512 KB |
Output is correct |
26 |
Correct |
2 ms |
256 KB |
Output is correct |
27 |
Correct |
2 ms |
256 KB |
Output is correct |
28 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
29 |
Halted |
0 ms |
0 KB |
- |