# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
13857 |
2015-04-08T07:30:50 Z |
gs14004 |
사회적 불평등 (TOKI14_social) |
C++14 |
|
300 ms |
1944 KB |
#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];
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);
int p = 0;
long long ret = 0;
for (int i=1; i<=MAX; i++) {
int j = p;
while (j < n && a[j].first == i) j++;
while (p < j) {
long long q = 0;
for (int k=a[p].second; k<=MAX; k++) {
q += t[k] * (k - a[p].second);
}
for (int k=a[p].second; k; k--) {
q += t[k] * (a[p].second - k);
}
elem[a[p].second]++;
p++;
ret += q;
}
for (int k=1; k<=MAX; k++) {
t[k] += elem[k];
}
}
printf("%lld",ret);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
1944 KB |
Output is correct |
2 |
Correct |
93 ms |
1944 KB |
Output is correct |
3 |
Correct |
89 ms |
1944 KB |
Output is correct |
4 |
Correct |
93 ms |
1944 KB |
Output is correct |
5 |
Correct |
93 ms |
1944 KB |
Output is correct |
6 |
Correct |
94 ms |
1944 KB |
Output is correct |
7 |
Correct |
105 ms |
1944 KB |
Output is correct |
8 |
Correct |
119 ms |
1944 KB |
Output is correct |
9 |
Correct |
143 ms |
1944 KB |
Output is correct |
10 |
Correct |
175 ms |
1944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
300 ms |
1944 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
300 ms |
1944 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
300 ms |
1944 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |