Triathlon - CodeChef
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)
#define all(x) (x).begin(), (x).end()
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define inf LLONG_MAX
#define mxm 200005
#define mod 1000000007
#define pi acos(-1)
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector< pll > vll;
typedef vector<string> vs;
typedef vector<ll> vL;
typedef unsigned long long ull;
typedef double D;
typedef long double LD;
//int dx[]= {0,0,-1,1,1,-1,1,-1};
//int dy[]= {-1,1,0,0,1,-1,-1,1};
ll n, x[mxm], y[mxm], z[mxm], id, sum = 0, mn = inf, mx = -1;
int main() {
scanf("%lld", &n);
for (int i = 0; i < n; i++)
{
scanf("%lld %lld %lld", &x[i], &y[i], &z[i]);
sum += x[i];
if (y[i] + z[i] < mn)
mn = y[i] + z[i];
if (y[i] + z[i] > mx){
mx = y[i] + z[i];
id = i;}
}
if (mx > sum-x[id] + mn)
printf("%lld\n", mx+x[id]);
else
printf("%lld\n", sum+mn);
return 0;
}
No comments:
Post a Comment