UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#171358#995. 新年礼物heyuzhen1000ms1212kbC++456b2023-06-22 21:55:162023-06-22 21:55:18

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dou double
ll m,n,a[1005],ans;
bool x[1005];
int main(){
	cin >> m >> n;
	for(ll i = 1;i <= n;i++)
		cin >> a[i];
	sort(a + 1,a + n + 1);
	reverse(a + 1,a + n + 1);
	for(ll i = 1;i <= n;i++)
		if(!x[i]){
			ans++;
			x[i] = 1;
			for(ll j = 1;j <= n;j++)
				if(x[j] == 0 && a[j] + a[i] <= m){
					x[j] = 1;
					break;
				}
		}
	cout << ans;
	return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 20
Accepted
time: 0ms
memory: 1208kb

input:

177
14
47
114
159
109
81
115
8
40
83
157
122
121
41
117

output:

9

result:

ok single line: '9'

Test #2:

score: 20
Accepted
time: 0ms
memory: 1212kb

input:

104
5
12
8
52
74
54

output:

3

result:

ok single line: '3'

Test #3:

score: 20
Accepted
time: 0ms
memory: 1212kb

input:

119
12
98
111
108
15
39
84
15
31
7
49
62
107

output:

7

result:

ok single line: '7'

Test #4:

score: 20
Accepted
time: 0ms
memory: 1208kb

input:

192
3
42
192
21

output:

2

result:

ok single line: '2'

Test #5:

score: 20
Accepted
time: 0ms
memory: 1212kb

input:

88
13
77
83
38
67
66
8
57
88
67
50
88
88
13

output:

10

result:

ok single line: '10'