Submission #61288

#TimeUsernameProblemLanguageResultExecution timeMemory
61288zetapiIdeal city (IOI12_city)C++14
0 / 100
9 ms1972 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ll long long #define itr ::iterator typedef pair<int,int> pii; const int MAX=1e5; const int mod=1e9; ll res1,res2,sum[MAX]; int DistanceSum(int N, int *X, int *Y) { int f=X[0],s=Y[0],f_=X[0],s_=Y[0]; for(int A=1;A<N;A++) { f=max(f,X[A]); s=max(s,Y[A]); f_=min(f_,X[A]); s_=min(s_,Y[A]); } f=f-f_; s=s-s_; for(ll A=1;A<MAX;A++) sum[A]=(sum[A-1]+A)%mod; for(ll A=1;A<=s;A++) { res1+=((A*(A-1))%mod-sum[A-1]+mod)%mod; res1%=mod; } for(ll A=1;A<=f;A++) { res2+=(((A*(A-1))%mod)-sum[A-1]+mod)%mod; res2%=mod; } return (int)((res1*f)%mod+(res2*s)%mod)%mod; } /*signed main() { ios_base::sync_with_stdio(false); int X[]={2,2,3,3,4,4,4,4,5,5,5}; int Y[]={5,6,3,6,3,4,5,6,3,4,6}; cout<<DistanceSum(11,X,Y); return 0; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...