QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#407356#8225. 最小值之和starry-sky-1550 0ms1580kbC++141.3kb2024-05-08 16:28:422024-05-08 16:28:44

Judging History

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

  • [2024-05-08 16:28:44]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:1580kb
  • [2024-05-08 16:28:42]
  • 提交

answer

#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
int T, n, a, b, _sum, cnt[10], tmp;
signed main() {
	scanf("%lld", &T);
	while (T --) {
		scanf("%lld", &n);
		_sum = 0;
		memset(cnt, 0, sizeof(cnt));
		for (int i = 1; i <= n; i ++) {
			scanf("%lld.%lld", &a, &b);
			_sum += a;
			if (b >= 5) {
				_sum ++;
			} else {
				cnt[b] ++;
			}
		}
		tmp = min(cnt[4], cnt[1]);
		_sum += tmp;
		cnt[4] -= tmp;
		cnt[1] -= tmp;
		
		tmp = min(cnt[3], cnt[2]);
		_sum += tmp;
		cnt[3] -= tmp;
		cnt[2] -= tmp;
		
		tmp = min(cnt[3], cnt[1] / 2);
		_sum += tmp;
		cnt[3] -= tmp;
		cnt[1] -= tmp * 2;
		
		tmp = min(cnt[2] / 2, cnt[1]);
		_sum += tmp;
		cnt[2] -= tmp * 2;
		cnt[1] -= tmp;
		
		tmp = min(cnt[2], cnt[1] / 3);
		_sum += tmp;
		cnt[2] -= tmp;
		cnt[1] -= tmp * 3;
		
		_sum += cnt[1] / 5;
		cnt[1] %= 5;
		
		tmp = min(cnt[4], cnt[2]);
		_sum += tmp;
		cnt[4] -= tmp;
		cnt[1] -= tmp;
		
		_sum += cnt[3] / 2;
		cnt[3] %= 2;
		
		_sum += cnt[2] / 3;
		cnt[2] %= 3;
		
		tmp = min(cnt[4], cnt[3]);
		_sum += tmp;
		cnt[4] -= tmp;
		cnt[3] -= tmp;
		
		_sum += cnt[4] / 2;
		cnt[4] %= 2;
		
		tmp = 0;
		for (int i = 1; i <= 4; i ++) {
			tmp += cnt[i] * i;
		}
		_sum += tmp / 10;
		printf("%lld\n", _sum);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1580kb

input:

5
14 14 12 13 13

output:

182
182
182
182
182

result:

wrong answer Line 1 expected 

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%