結果
| 問題 |
No.844 split game
|
| コンテスト | |
| ユーザー |
QCFium
|
| 提出日時 | 2019-06-28 22:03:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 804 bytes |
| コンパイル時間 | 2,209 ms |
| コンパイル使用メモリ | 178,532 KB |
| 最終ジャッジ日時 | 2025-03-13 09:11:24 |
| 合計ジャッジ時間 | 4,285 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int ri()’:
main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
In file included from /usr/include/c++/13/string:43,
from /usr/include/c++/13/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
from main.cpp:4:
/usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::_Rb_tree_impl<std::less<int>, true>::~_Rb_tree_impl()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::_Rb_tree_node<std::pair<const int, int> >]’: target specific option mismatch
184 | ~allocator() _GLIBCXX_NOTHROW { }
| ^
In file included from /usr/include/c++/13/map:62,
from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:152:
/usr/include/c++/13/bits/stl_tree.h:662:16: note: called from here
662 | struct _Rb_tree_impl
| ^~~~~~~~~~~~~
ソースコード
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
int ri() {
int n;
scanf("%d", &n);
return n;
}
int main() {
int n = ri();
int m = ri();
int a = ri();
int l[m], r[m], p[m];
for (int i = 0; i < m; i++) l[i] = ri() - 1, r[i] = ri() - 1, p[i] = ri();
std::map<int, int> ranges[n];
for (int i = 0; i < m; i++) ranges[l[i]].insert({r[i], p[i]});
int64_t dp[n + 1];
for (int i = 0; i <= n; i++) dp[i] = -1000000007;
dp[0] = 0;
int64_t chmax = -1000000007;
for (int i = 0; i < n; i++) {
dp[i] = std::max(dp[i], chmax);
chmax = std::max(chmax, dp[i] - a);
for (auto j : ranges[i]) dp[j.first + 1] = std::max(dp[j.first + 1], dp[i] - a + j.second);
}
std::cout << std::max(chmax, dp[n]) + a << std::endl;
return 0;
}
QCFium