This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// High above the clouds there is a rainbow...
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=100,mod=1e9+7;
const ll inf=1e18;
ll val[maxn][maxn];
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);
int n,m;cin>>n>>m;
for(int i=0;i<m;i++){
int a,b;cin>>a>>b; --a,--b;
ll X;cin>>X;
for(int x=a;x!=b;x= (x+1)%n)
for(int y=b; y!=a; y= (y+1)%n)
val[x][y]+=X, val[y][x]+=X;
}
ll ans=0;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
ans=max(ans, val[i][j]);
return cout<<(ans+1)/2<<endl,0;
}
// Deathly mistakes:
// * Read the problem curfully.
// * Check maxn.
// * Overflows.
# | 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... |