Submission #13858

#TimeUsernameProblemLanguageResultExecution timeMemory
13858gs14004사회적 불평등 (TOKI14_social)C++14
29 / 100
300 ms1944 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...