This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<int,int> pi;
const int MAX = 10000;
int n;
pi a[100005];
int elem[10005], t[10005];
long long solve(){
long long ret = 0;
for (int i=0; i<n; i++) {
for (int j=i+1; j<n; j++) {
if(a[i].second < a[j].second){
ret += (a[j].second - a[i].second) * (a[j].first - a[i].first);
}
}
}
return ret;
}
int main(){
scanf("%d",&n);
for (int i=0; i<n; i++) {
scanf("%d %d",&a[i].first,&a[i].second);
}
sort(a,a+n);
long long ret = solve();
for (int i=0; i<n; i++) {
a[i].second = MAX + 1 - a[i].second;
}
ret += solve();
printf("%lld",ret);
}
# | 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... |