QOJ.ac

QOJ

ID提交记录ID题目HackerOwner结果提交时间测评时间
#908#477539#9129. Quotient SumFDUdululuucup-team2000Success!2024-09-26 15:38:152024-09-26 15:38:15

詳細信息

Extra Test:

Wrong Answer
time: 0ms
memory: 3572kb

input:

18
576 1437 1894 3522 6069 6400 7774 9034 14482 18201 20584 22436 22889 24585 24605 24899 27142 31725

output:

9

result:

wrong answer 1st words differ - expected: '8', found: '9'

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#477539#9129. Quotient Sumucup-team2000#WA 34ms4772kbC++14485b2024-07-14 05:17:452024-10-14 07:35:08

answer

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

void solve() {
	int n; cin >> n;
	vector<ll> a(n); for (auto& x : a) cin >> x;
	sort(a.begin(), a.end(), greater<ll>());

	ll pr = a[0], ans = 0;
	for (int i = 1; i < n - 1; i++) {
		if (pr / a[i] + a[i] / a[i + 1] <= pr / a[i + 1]) {
			ans += pr / a[i];
			pr = a[i];
		}
	}
	ans += pr / a[n-1];
	cout << ans << "\n";
}

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

	int t = 1;
	while (t--) solve();
}