QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#687244#6472. RobotsPetroTarnavskyi#AC ✓2ms3980kbC++231.0kb2024-10-29 17:46:532024-10-29 17:46:54

Judging History

你现在查看的是最新测评结果

  • [2024-10-29 17:46:54]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3980kb
  • [2024-10-29 17:46:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;

LL calcD(int n, vector<PLL> as)
{
	LL v = 0;
	LL ans = 0;
	
	for(auto [a, t] : as)
	{
		ans += 2 * v * t + a * t * t;
		v += a * t;
	}
	return ans;
}



int main()
{
	ios::sync_with_stdio(0); 
	cin.tie(0);

	int n;
	cin >> n;
	
	vector<PLL> as(n);
	FOR(i, 0, n)
		cin >> as[i].F >> as[i].S;
	//FOR(i, 0, n)
	//	cin >> as[i].S;
	
	LL d0 = calcD(n, as);
	sort(ALL(as), greater());
	LL d1 = calcD(n, as);
	
	//cerr << d0 << " " << d1 << "\n";
	d1 -= d0;
	
	cout << d1 / 2 << "." << (d1 % 2 == 1 ? 5 : 0) << "\n";
	
	
	
	
	
	

	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3624kb

input:

1
10 30000

output:

0.0

result:

ok single line: '0.0'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

2
2 1
30 2

output:

56.0

result:

ok single line: '56.0'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

5
2 5
7 4
12 3
10 1
9 15

output:

1007.0

result:

ok single line: '1007.0'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

10
1 10
2 9
3 8
4 7
5 6
6 5
7 4
8 3
9 2
10 1

output:

4158.0

result:

ok single line: '4158.0'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

100
100 100
99 99
98 98
97 97
96 96
95 95
94 94
93 93
92 92
91 91
90 90
89 89
88 88
87 87
86 86
85 85
84 84
83 83
82 82
81 81
80 80
79 79
78 78
77 77
76 76
75 75
74 74
73 73
72 72
71 71
70 70
69 69
68 68
67 67
66 66
65 65
64 64
63 63
62 62
61 61
60 60
59 59
58 58
57 57
56 56
55 55
54 54
53 53
52 52
...

output:

0.0

result:

ok single line: '0.0'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

1000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1 2000
1...

output:

0.0

result:

ok single line: '0.0'

Test #7:

score: 0
Accepted
time: 2ms
memory: 3780kb

input:

10000
2 2
3 3
4 1
5 2
6 3
7 1
8 2
9 3
10 1
1 2
2 3
3 1
4 2
5 3
6 1
7 2
8 3
9 1
10 2
1 3
2 1
3 2
4 3
5 1
6 2
7 3
8 1
9 2
10 3
1 1
2 2
3 3
4 1
5 2
6 3
7 1
8 2
9 3
10 1
1 2
2 3
3 1
4 2
5 3
6 1
7 2
8 3
9 1
10 2
1 3
2 1
3 2
4 3
5 1
6 2
7 3
8 1
9 2
10 3
1 1
2 2
3 3
4 1
5 2
6 3
7 1
8 2
9 3
10 1
1 2
2 3
3 1...

output:

330203937.0

result:

ok single line: '330203937.0'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3980kb

input:

5000
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1
10 1
11 1
12 1
13 1
14 1
15 1
16 1
17 1
18 1
19 1
20 1
21 1
22 1
23 1
24 1
25 1
26 1
27 1
28 1
29 1
30 1
31 1
32 1
33 1
34 1
35 1
36 1
37 1
38 1
39 1
40 1
41 1
42 1
43 1
44 1
45 1
46 1
47 1
48 1
49 1
50 1
51 1
52 1
53 1
54 1
55 1
56 1
57 1
58 1
59 1
60 1
61 1...

output:

20833332500.0

result:

ok single line: '20833332500.0'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

50
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50

output:

0.0

result:

ok single line: '0.0'