結果
問題 |
No.3302 Sense Battle
|
ユーザー |
![]() |
提出日時 | 2025-10-07 09:11:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 193 ms / 2,000 ms |
コード長 | 763 bytes |
コンパイル時間 | 450 ms |
コンパイル使用メモリ | 42,084 KB |
実行使用メモリ | 118,400 KB |
最終ジャッジ日時 | 2025-10-07 09:11:56 |
合計ジャッジ時間 | 3,779 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:32:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 32 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:33:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 33 | for (int i = 0; i < n; i++) scanf("%d%d", as + i, bs + i); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 3302.cc: No.3302 Sense Battle - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 5000; /* typedef */ using ll = long long; /* global variables */ int as[MAX_N], bs[MAX_N]; ll dp[MAX_N + 1][MAX_N + 1]; /* subroutines */ inline void setmax(ll &a, ll b) { if (a < b) a = b; } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d%d", as + i, bs + i); for (int i = n - 1; i >= 0; i--) for (int j = 0; i + j < n; j++) { setmax(dp[i][j], dp[i + 1][j] + (ll)as[i] * j); setmax(dp[i][j + 1], dp[i + 1][j] + bs[i]); } ll maxd = *max_element(dp[0], dp[0] + n + 1); printf("%lld\n", maxd); return 0; }