QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#476674 | #9129. Quotient Sum | Forever_Young# | WA | 0ms | 3952kb | C++14 | 705b | 2024-07-13 20:42:32 | 2024-07-13 20:42:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define all(x) ((x).begin()), ((x).end())
#define pb push_back
const int N = 200022;
LL a[N];
int main() {
int n;
scanf("%d", &n);
for(int i = 0; i < n; i++) {
scanf("%lld", &a[i]);
}
sort(a, a + n);
reverse(a, a + n);
for (int i = 0, j; i + 1 < n; i = j) {
for (j = i + 1; j < n && a[i] / a[j] == a[i] / a[i + 1]; j++);
if (j < n && a[j - 1] / a[j] < a[i + 1] / a[j]) {
j--;
}
reverse(a + i + 1, a + j);
}
LL ans = 0;
for (int i = 0; i + 1 < n; i++) {
ans += a[i] / a[i + 1];
}
printf("%lld\n", ans);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3816kb
input:
3 2 3 6
output:
3
result:
ok "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3952kb
input:
2 15 4
output:
3
result:
ok "3"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3952kb
input:
9 284791808 107902 13660981249408 4622332661 13405199 24590921 361 244448137 16077087227955422
output:
4580
result:
ok "4580"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3792kb
input:
9 12 9 5 17 2 6 7 1 15
output:
8
result:
wrong answer 1st words differ - expected: '6', found: '8'