답안 #240106

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
240106 2020-06-18T05:21:11 Z MrRobot_28 Go (COCI18_go) C++17
40 / 100
26 ms 1280 KB
#include <bits/stdc++.h>
                  
using namespace std;
bool cmp(pair <pair <int, int>, int> a, pair <pair <int, int>, int> b)
{
	return a.second < b.second;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, k, m;
	cin >> n >> k >> m;
	vector <vector <int> > dp(m, vector <int> (2001, -1e9));
	vector <pair <pair <int, int>, int> > mass(m);
	for(int i = 0; i < m; i++)
	{
		cin >> mass[i].first.first >> mass[i].first.second >> mass[i].second;
	}
	sort(mass.begin(), mass.end(), cmp);
	int ans = 0;
	for(int i = 0; i < mass.size(); i++)
	{
		if(abs(mass[i].first.first - k) <= mass[i].second - 1)
		{
			dp[i][abs(mass[i].first.first - k)] = max(dp[i][abs(mass[i].first.first - k)], mass[i].first.second);
		}
		for(int j = 0; j < i; j++)
		{
			for(int t = 0; t <= 2000; t++)
			{
				int del = abs(mass[i].first.first - mass[j].first.first);
				if(del + t >= mass[i].second)
				{
					continue;
				}
				dp[i][t + del] = max(dp[i][t + del], dp[j][t] + mass[i].first.second);
			}
		}
		for(int t = 0; t <= 2000; t++)
		{
			ans = max(ans, dp[i][t]);
		}
	}
	cout << ans;
	return 0;
}

Compilation message

go.cpp: In function 'int main()':
go.cpp:22:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < mass.size(); i++)
                 ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Correct 5 ms 488 KB Output is correct
5 Correct 9 ms 768 KB Output is correct
6 Incorrect 12 ms 896 KB Output isn't correct
7 Incorrect 15 ms 896 KB Output isn't correct
8 Incorrect 19 ms 1024 KB Output isn't correct
9 Incorrect 18 ms 1024 KB Output isn't correct
10 Incorrect 26 ms 1280 KB Output isn't correct