제출 #348964

#제출 시각아이디문제언어결과실행 시간메모리
348964shrek12357Salesman (IOI09_salesman)C++14
17 / 100
3096 ms14512 KiB
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <set> #include <climits> #include <cmath> #include <fstream> #include <queue> #include <stack> #include <iomanip> #include <bitset> //#include "network.h" using namespace std; #define ll long long //cin.tie(0);ios_base::sync_with_stdio(0); const int MAXN = 1e5 + 5; ll dp[MAXN]; int main() { //ifstream cin("bcount.in"); ofstream cout("bcount.out"); int n, u, d, s; cin >> n >> u >> d >> s; vector<pair<int, pair<int, int>>> nums; for (int i = 0; i < n; i++) { int t, l, x; cin >> t >> l >> x; nums.push_back({ t, {l, x} }); } nums.push_back({ 0, {s, 0} }); nums.push_back({ 100000, {s, 0} }); sort(nums.begin(), nums.end()); for (int i = 0; i < nums.size(); i++) { dp[i] = -1e12; } dp[0] = 0; for (int i = 0; i < nums.size(); i++) { for (int j = 0; j < i; j++) { if (nums[j].second.first > nums[i].second.first) { dp[i] = max(dp[i], dp[j] + nums[i].second.second - (nums[j].second.first - nums[i].second.first) * u); } else { dp[i] = max(dp[i], dp[j] + nums[i].second.second - (nums[i].second.first - nums[j].second.first) * d); } } } /*int ans = 0; for (int i = 0; i < n; i++) { if (nums[i].second.first > s) { ans = max(ans, dp[i] - (nums[i].second.first - s) * u); } else { ans = max(ans, dp[i] - (s - nums[i].second.first) * d); } }*/ cout << dp[nums.size() - 1] << endl; }

컴파일 시 표준 에러 (stderr) 메시지

salesman.cpp: In function 'int main()':
salesman.cpp:36:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for (int i = 0; i < nums.size(); i++) {
      |                  ~~^~~~~~~~~~~~~
salesman.cpp:40:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |  for (int i = 0; i < nums.size(); i++) {
      |                  ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...