QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#296111 | #5072. Future Coder | zyzakioi | WA | 0ms | 3564kb | C++14 | 1.1kb | 2024-01-02 09:55:55 | 2024-01-02 09:55:55 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
int t, n, a;
vector<int>pos, neg;
int get1(int now) {
int l = 0, r = pos.size() - 1, mid, ans = pos.size();
while (l <= r) {
mid = (l + r) >> 1;
if (pos[mid] * now < pos[mid] + now) {
ans = mid;
r = mid - 1;
}
else
l = mid + 1;
}
return pos.size() - ans + 1;
}
int get2(int s, int e, int now) {
int l = s, r = e, mid, ans = s;
while (l <= r) {
mid = (l + r) >> 1;
if (pos[mid] * now < pos[mid] + now) {
ans = mid;
l = mid + 1;
}
else
r = mid - 1;
}
return ans - s;
}
signed main() {
cin >> t;
while (t--) {
cin >> n;
pos.clear();
neg.clear();
for (int i = 1; i <= n; ++i) {
cin >> a;
if (a >= 0)
pos.push_back(a);
else
neg.push_back(a);
}
sort(pos.begin(), pos.end());
sort(neg.begin(), neg.end());
if (!pos.size()) {
cout << 0 << endl;
continue;
}
long long ans = 0;
for (auto i : neg)
ans += get1(i);
for (int i = 0; i < pos.size(); ++i)
ans += get2(i, pos.size() - 1, pos[i]);
cout << ans << endl;
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3564kb
input:
2 8 3 -1 4 1 -5 9 2 -6 1 0
output:
22 0
result:
wrong answer 1st numbers differ - expected: '19', found: '22'