제출 #921559

#제출 시각아이디문제언어결과실행 시간메모리
921559josanneo22Salesman (IOI09_salesman)C++17
17 / 100
3079 ms22616 KiB
#pragma warning(suppress : 4996) #include <bits/stdc++.h> using namespace std; using i64 = long long; #define L(i,j,k) for(int i=(j);i<=(k);++i) #define R(i,j,k) for(int i=(j);i>=(k);--i) #define all(x) x.begin(),x.end() #define me(x,a) memset(x,a,sizeof(x)) int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int N; i64 U, D, S; cin >> N >> U >> D >> S; //dp[i] = max profit after considering all events until i //dp[i] = dp[j] + (pos[i] - pos[j]) * U if pos[i] < pos[j] //dp[i] = dp[j] + (pos[j] - pos[i]) * D if pos[i] > pos[j] vector<i64> dp(N + 2, -1E18); vector<i64> date(N + 2), pos(N + 2), profit(N + 2); L(i, 1, N) cin >> date[i] >> pos[i] >> profit[i]; pos[0] = S; date[0] = -1E18; pos[N + 1] = S; date[N + 1] = 1E18; vector<int> ord(N + 2); iota(all(ord), 0); sort(ord.begin(), ord.end(), [&](int i, int j) { return date[i] < date[j]; }); dp[0] = 0; L(i, 1, N + 1) { L(j, 0, i - 1) { if (pos[ord[i]] <= pos[ord[j]]) dp[i] = max(dp[i], dp[j] + profit[ord[i]] - (pos[ord[j]] - pos[ord[i]]) * D); else dp[i] = max(dp[i], dp[j] + profit[ord[i]] - (pos[ord[i]] - pos[ord[j]]) * U); } } cout << dp[N + 1] << '\n'; }

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

salesman.cpp:1: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
    1 | #pragma warning(suppress : 4996)
      |
#Verdict Execution timeMemoryGrader output
Fetching results...