Submission #240106

#TimeUsernameProblemLanguageResultExecution timeMemory
240106MrRobot_28Go (COCI18_go)C++17
40 / 100
26 ms1280 KiB
#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 (stderr)

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++)
                 ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...