QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#261617 | #6472. Robots | illyakr# | AC ✓ | 1ms | 3772kb | C++17 | 964b | 2023-11-23 03:27:56 | 2023-11-23 03:27:57 |
Judging History
answer
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define int long long
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
signed main(){
cin.tie(0);
ios::sync_with_stdio(0);
int n;
cin >> n;
vector<pair<int,int>> a(n);
for(int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
int v = 0, d = 0;
for(int i = 0; i < n; i++){
d += 2*v*a[i].second + a[i].first*a[i].second*a[i].second;
v += a[i].first * a[i].second;
}
int norm = d;
for(int i = 0; i < n; i++) a[i].second = -a[i].second;
sort(a.rbegin(),a.rend());
for(int i = 0; i < n; i++) a[i].second = -a[i].second;
v = 0, d = 0;
for(int i = 0; i < n; i++){
d += 2*v*a[i].second + a[i].first*a[i].second*a[i].second;
v += a[i].first * a[i].second;
}
int opt = d;
cout << (opt-norm)/2 << "." << 5*((opt-norm)%2) << "\n";
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3580kb
input:
1 10 30000
output:
0.0
result:
ok single line: '0.0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
2 2 1 30 2
output:
56.0
result:
ok single line: '56.0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3736kb
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: 3468kb
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: 3736kb
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: 1ms
memory: 3756kb
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: 1ms
memory: 3772kb
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: 3684kb
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: 3604kb
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'