QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#477585#9129. Quotient Sumucup-team3695#WA 0ms3624kbC++20929b2024-07-14 06:30:382024-07-14 06:30:38

Judging History

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

  • [2024-09-26 15:38:30]
  • hack成功,自动添加数据
  • (/hack/908)
  • [2024-07-14 06:30:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3624kb
  • [2024-07-14 06:30:38]
  • 提交

answer

#include <bits/stdc++.h>
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;
#define pb push_back
#define mp make_pair


#define MAXN 200'010
ll a[MAXN];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n;
	cin >> n;
	rep(i, 0, n) cin >> a[i];

	sort(a, a+n);
	ll out = LLONG_MAX;

	rep(blah, 0, 2) {
	
	ll med = 0;
	rep(i, 0, n-1) med += a[i+1]/a[i];
	med += a[0]/a[n-1];

	out = min(out, med);


	rep(i, 1, n-1) {
		// [0, i] decreasing
		// [i+1, n] increasing

		// i was before i+1 and after 0
		med -= a[i+1]/a[i];
		med -= a[i]/a[0];

		// i+1 is now after 0, i is now after n-1
		med += a[i+1]/a[0];
		med += a[i]/a[n-1];

		out = min(out, med);
	}

	}

	cout << out << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
2 3 6

output:

3

result:

ok "3"

Test #2:

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

input:

2
15 4

output:

3

result:

ok "3"

Test #3:

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

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: 3544kb

input:

9
12 9 5 17 2 6 7 1 15

output:

10

result:

wrong answer 1st words differ - expected: '6', found: '10'