제출 #823938

#제출 시각아이디문제언어결과실행 시간메모리
823938LiudasSalesman (IOI09_salesman)C++17
15 / 100
76 ms6196 KiB
#include <bits/stdc++.h> using namespace std; int N, U, D, S; struct node{ int pos; int pro; int day; bool operator<(node a){ } }; int main() { cin >> N >> U >> D >> S; vector<node> arr(N+1, {0, 0, 0}), brr; arr[0].day = -1; arr[0].pos = S; if(N > 5000){ return 0; } for(int i = 1; i <= N; i ++){ cin >> arr[i].day >> arr[i].pos >> arr[i].pro; } brr = arr; sort(arr.begin(), arr.end(), [&](node a, node b){ if(b.day == a.day){ return a.pos < b.pos; } return a.day < b.day;}); sort(brr.begin(), brr.end(), [&](node a, node b){ if(b.day == a.day){ return a.pos > b.pos; } return a.day < b.day;}); vector<int> DP(N+1), DPL(N+1, 0), DPR(N+1, 0); for(int i = 1; i <= N; i ++){ int it = i; int mx = -1e9; while(it + 1 <= N && arr[it].day == arr[it + 1].day)it++; for(int k = i; k <= it; k ++){ for(int j = 0; j < k; j ++){ mx = max(mx, -(arr[j].pos - arr[k].pos > 0 ? (arr[j].pos - arr[k].pos) * D : -(arr[j].pos - arr[k].pos) * U) + DP[j]); } DPL[k] = mx + arr[k].pro; DP[k] = mx + arr[k].pro; } mx = -1e9; for(int k = i; k <= it; k ++){ for(int j = 0; j < k; j ++){ mx = max(mx, -(brr[j].pos - brr[k].pos > 0 ? (brr[j].pos - brr[k].pos) * D : -(brr[j].pos - brr[k].pos) * U) + DP[j]); } DPR[k] = mx + brr[k].pro; DP[k] = mx + brr[k].pro; } for(int k = i; k <= it; k ++){ DP[k] = max(DPL[k], DPR[k]); } i = it; } int ans = 0; for(int i = 0; i <= N; i ++){ ans = max(ans, DP[i] - (S - arr[i].pos > 0 ? (S - arr[i].pos) * U : -(S - arr[i].pos) * D)); } cout << ans << endl; return 0; }

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

salesman.cpp: In member function 'bool node::operator<(node)':
salesman.cpp:10:5: warning: no return statement in function returning non-void [-Wreturn-type]
   10 |     }
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...