답안 #757967

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
757967 2023-06-14T03:13:18 Z jer033 Gym Badges (NOI22_gymbadges) C++17
24 / 100
218 ms 4380 KB
#include <algorithm>
#include <iostream>

long long xis[500005];
long long lis[500005];
int permu[11];
using namespace std;

int main()
{
	int n;
	cin >> n;
	if (n<=10)
	{
		for (int i=1; i<=n; i++)
		{
			cin >> xis[i];
		}
		for (int i=1; i<=n; i++)
		{
			cin >> lis[i];
		}
		//code the brute force
		int nfactorial=1;
		for (int i=2; i<=n; i++)
			nfactorial*=i;
		for (int i=1; i<=n; i++)
			permu[i]=i;
		int maxbadges=0;
		for (int i=1; i<=nfactorial; i++)
		{
			//check how far it goes
			int badgec=1;
			long long level=xis[permu[1]];
			while (badgec<n and level<=lis[permu[badgec+1]])
			{
				level+=xis[permu[badgec+1]];
				badgec++;
			}
			maxbadges=max(maxbadges, badgec);
			//code the next permutation
			int swapa=n-1;
			while (permu[swapa]>permu[swapa+1])
				swapa--;
			int swapb=swapa+1;
			for (int j=swapa+2; j<=n; j++)
			{
				if (permu[j]>permu[swapa])
					swapb=j;
			}
			int x=permu[swapa];
			permu[swapa]=permu[swapb];
			permu[swapb]=x;
			sort(permu+swapa+1, permu+n+1);
		}
		cout << maxbadges << '\n';
	}
	else
	{
		for (int i=0; i<n; i++)
		{
			cin >> xis[i];
		}
		sort(xis, xis+n);
		long long li;
		cin >> li;
		int badge=0;
		long long level=0;
		while (level<=li)
		{
			level+=xis[badge];
			badge++;
		}
		cout << badge << '\n';
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 57 ms 288 KB Output is correct
4 Correct 60 ms 212 KB Output is correct
5 Correct 61 ms 288 KB Output is correct
6 Correct 59 ms 212 KB Output is correct
7 Correct 6 ms 308 KB Output is correct
8 Correct 60 ms 292 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 75 ms 212 KB Output is correct
14 Correct 62 ms 212 KB Output is correct
15 Correct 61 ms 292 KB Output is correct
16 Correct 6 ms 212 KB Output is correct
17 Correct 8 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 79 ms 212 KB Output is correct
20 Correct 90 ms 288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 201 ms 4196 KB Output is correct
2 Correct 211 ms 4172 KB Output is correct
3 Correct 218 ms 4348 KB Output is correct
4 Correct 192 ms 4124 KB Output is correct
5 Correct 213 ms 4196 KB Output is correct
6 Correct 166 ms 4300 KB Output is correct
7 Correct 173 ms 4232 KB Output is correct
8 Correct 186 ms 4208 KB Output is correct
9 Correct 180 ms 4200 KB Output is correct
10 Correct 167 ms 4168 KB Output is correct
11 Correct 136 ms 4180 KB Output is correct
12 Correct 137 ms 4132 KB Output is correct
13 Correct 135 ms 4132 KB Output is correct
14 Correct 154 ms 4204 KB Output is correct
15 Correct 174 ms 4200 KB Output is correct
16 Correct 175 ms 4380 KB Output is correct
17 Correct 166 ms 4200 KB Output is correct
18 Correct 170 ms 4136 KB Output is correct
19 Correct 163 ms 4124 KB Output is correct
20 Correct 163 ms 4192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 57 ms 288 KB Output is correct
4 Correct 60 ms 212 KB Output is correct
5 Correct 61 ms 288 KB Output is correct
6 Correct 59 ms 212 KB Output is correct
7 Correct 6 ms 308 KB Output is correct
8 Correct 60 ms 292 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 75 ms 212 KB Output is correct
14 Correct 62 ms 212 KB Output is correct
15 Correct 61 ms 292 KB Output is correct
16 Correct 6 ms 212 KB Output is correct
17 Correct 8 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 79 ms 212 KB Output is correct
20 Correct 90 ms 288 KB Output is correct
21 Incorrect 3 ms 340 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 57 ms 288 KB Output is correct
4 Correct 60 ms 212 KB Output is correct
5 Correct 61 ms 288 KB Output is correct
6 Correct 59 ms 212 KB Output is correct
7 Correct 6 ms 308 KB Output is correct
8 Correct 60 ms 292 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 75 ms 212 KB Output is correct
14 Correct 62 ms 212 KB Output is correct
15 Correct 61 ms 292 KB Output is correct
16 Correct 6 ms 212 KB Output is correct
17 Correct 8 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 79 ms 212 KB Output is correct
20 Correct 90 ms 288 KB Output is correct
21 Correct 201 ms 4196 KB Output is correct
22 Correct 211 ms 4172 KB Output is correct
23 Correct 218 ms 4348 KB Output is correct
24 Correct 192 ms 4124 KB Output is correct
25 Correct 213 ms 4196 KB Output is correct
26 Correct 166 ms 4300 KB Output is correct
27 Correct 173 ms 4232 KB Output is correct
28 Correct 186 ms 4208 KB Output is correct
29 Correct 180 ms 4200 KB Output is correct
30 Correct 167 ms 4168 KB Output is correct
31 Correct 136 ms 4180 KB Output is correct
32 Correct 137 ms 4132 KB Output is correct
33 Correct 135 ms 4132 KB Output is correct
34 Correct 154 ms 4204 KB Output is correct
35 Correct 174 ms 4200 KB Output is correct
36 Correct 175 ms 4380 KB Output is correct
37 Correct 166 ms 4200 KB Output is correct
38 Correct 170 ms 4136 KB Output is correct
39 Correct 163 ms 4124 KB Output is correct
40 Correct 163 ms 4192 KB Output is correct
41 Incorrect 3 ms 340 KB Output isn't correct
42 Halted 0 ms 0 KB -