답안 #896236

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
896236 2024-01-01T03:59:57 Z MongHwa 만두 (JOI14_ho_t2) C++17
100 / 100
641 ms 1108 KB
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

#define X first
#define Y second
#define INF 0x7f7f7f7f

int arr[10005], dp[10005];
pair<int, int> box[10005];
multiset<int> ms;

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

	int m, n;
	cin >> m >> n;

	for(int i = 0; i < m; i++)
		cin >> arr[i];
	for(int i = 0; i < n; i++)
		cin >> box[i].X >> box[i].Y;

	sort(arr, arr+m, greater<>());

	fill(dp+1, dp+m+1, INF);

	for(int i = 0; i < n; i++)
	{
		ms.clear();
		for(int j = 0; j <= box[i].X; j++)
			if(m-j >= 0)
				ms.insert(dp[m-j]);
		
		for(int j = m; j >= 0; j--)
		{
			int temp = dp[j];
			dp[j] = min(dp[j], *ms.begin() + box[i].Y);
			ms.erase(ms.find(temp));
			if(j-box[i].X-1 >= 0)
				ms.insert(dp[j-box[i].X-1]);
		}
	}

	int ans = 0, sum = 0;
	for(int i = 0; i < m; i++)
	{
		sum += arr[i];
		ans = max(ans, sum-dp[i+1]);
	}

	cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 12 ms 860 KB Output is correct
4 Correct 12 ms 860 KB Output is correct
5 Correct 10 ms 604 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 11 ms 1040 KB Output is correct
10 Correct 12 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 228 ms 584 KB Output is correct
2 Correct 197 ms 600 KB Output is correct
3 Correct 199 ms 500 KB Output is correct
4 Correct 209 ms 344 KB Output is correct
5 Correct 197 ms 548 KB Output is correct
6 Correct 20 ms 344 KB Output is correct
7 Correct 157 ms 344 KB Output is correct
8 Correct 196 ms 552 KB Output is correct
9 Correct 20 ms 352 KB Output is correct
10 Correct 194 ms 556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 12 ms 860 KB Output is correct
4 Correct 12 ms 860 KB Output is correct
5 Correct 10 ms 604 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 11 ms 1040 KB Output is correct
10 Correct 12 ms 604 KB Output is correct
11 Correct 228 ms 584 KB Output is correct
12 Correct 197 ms 600 KB Output is correct
13 Correct 199 ms 500 KB Output is correct
14 Correct 209 ms 344 KB Output is correct
15 Correct 197 ms 548 KB Output is correct
16 Correct 20 ms 344 KB Output is correct
17 Correct 157 ms 344 KB Output is correct
18 Correct 196 ms 552 KB Output is correct
19 Correct 20 ms 352 KB Output is correct
20 Correct 194 ms 556 KB Output is correct
21 Correct 528 ms 1056 KB Output is correct
22 Correct 555 ms 860 KB Output is correct
23 Correct 641 ms 856 KB Output is correct
24 Correct 597 ms 1108 KB Output is correct
25 Correct 606 ms 1064 KB Output is correct
26 Correct 600 ms 1020 KB Output is correct
27 Correct 114 ms 576 KB Output is correct
28 Correct 525 ms 604 KB Output is correct
29 Correct 423 ms 624 KB Output is correct
30 Correct 444 ms 604 KB Output is correct