提出 #42350573
ソースコード 拡げる
#pragma region header
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, j, n) for (ll i = (j); (i) < (n); ++(i))
#define pre(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define fs first
#define sd second
#define is insert
#define ft front
#define str = string
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define vs vector<string>
#define vpll vector<pair<ll, ll>>
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void yesno(bool flag) { cout << (flag ? "Yes" : "No") << endl; }
void YESNO(bool flag) { cout << (flag ? "YES" : "NO") << endl; }
void in() {};
template <class T, class... U> void in(T&& x, U &&...y) { cin >> x; in(forward<U>(y)...); }
int print() { /*cout << '\n';*/ return 0; }
template <class head, class... tail> int print(head&& h, tail&&... t) { cout << h << (sizeof...(t) ? ' ' : '\n'); return print(forward<tail>(t)...); }
#define inll(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define instr(...) string __VA_ARGS__; in(__VA_ARGS__)
template <class T> int print(vector<T>& a, char sep = ' ') { for (auto& val : a) cout << val << (&val != &a.back() ? sep : '\n'); return 0; }
template <class T>int print(vector<vector<T>>& a) { for (auto& row : a) print(row); return 0; }
/*cout << fixed << setprecision(15); for double*/
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else { return gcd(b, a % b); } }//最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }//最小公倍数
bool comp(pll& f, pll& s) { return f.second < s.second; }//昇順に並び替える比較関数
const double PI = 3.141592653589793;
const int INF32 = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 998244353;//1000000007;
using mint = modint1000000007; //998244353
ll dy[4] = { 1, -1, 0, 0 }, dx[4] = { 0, 0, 1, -1 };
// ll dy[8] = {1,1,1,0,0,-1,-1,-1}, dx[8] = {1,0,-1,1,-1,1,0,-1};
#pragma endregion header
int main() {
inll(N);
vll X(N), Y(N);
rep(i, N)cin >> X[i] >> Y[i];
vvll dp(N + 1, vll(2, 0));//何品目/状態(毒:1)
rep(i, N) {
if (X[i]) {
chmax(dp[i + 1][1], dp[i][0] + Y[i]);
chmax(dp[i + 1][1], dp[i][1]);
chmax(dp[i + 1][0], dp[i][0]);
}
else {
chmax(dp[i + 1][1], dp[i][1]);
chmax(dp[i + 1][0], dp[i][0]);
chmax(dp[i + 1][0], dp[i][0] + Y[i]);
chmax(dp[i + 1][0], dp[i][1] + Y[i]);
}
}
cout << max(dp[N][0], dp[N][1]) << endl;
return 0;
}
提出情報
コンパイルエラー
./Main.cpp:1: warning: ignoring #pragma region header [-Wunknown-pragmas]
1 | #pragma region header
|
./Main.cpp:49: warning: ignoring #pragma endregion header [-Wunknown-pragmas]
49 | #pragma endregion header
|
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
400 / 400 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
sample_01.txt, sample_02.txt, sample_03.txt |
| All |
sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| sample_01.txt |
AC |
7 ms |
3504 KiB |
| sample_02.txt |
AC |
2 ms |
3504 KiB |
| sample_03.txt |
AC |
2 ms |
3604 KiB |
| test_01.txt |
AC |
2 ms |
3460 KiB |
| test_02.txt |
AC |
2 ms |
3432 KiB |
| test_03.txt |
AC |
2 ms |
3360 KiB |
| test_04.txt |
AC |
1 ms |
3504 KiB |
| test_05.txt |
AC |
14 ms |
4972 KiB |
| test_06.txt |
AC |
102 ms |
18768 KiB |
| test_07.txt |
AC |
43 ms |
8556 KiB |
| test_08.txt |
AC |
15 ms |
5064 KiB |
| test_09.txt |
AC |
51 ms |
11988 KiB |
| test_10.txt |
AC |
126 ms |
23868 KiB |
| test_11.txt |
AC |
90 ms |
16148 KiB |
| test_12.txt |
AC |
79 ms |
19760 KiB |
| test_13.txt |
AC |
97 ms |
24052 KiB |
| test_14.txt |
AC |
35 ms |
8556 KiB |
| test_15.txt |
AC |
128 ms |
19716 KiB |
| test_16.txt |
AC |
74 ms |
18388 KiB |
| test_17.txt |
AC |
98 ms |
24392 KiB |
| test_18.txt |
AC |
125 ms |
24212 KiB |
| test_19.txt |
AC |
147 ms |
24392 KiB |
| test_20.txt |
AC |
100 ms |
24196 KiB |
| test_21.txt |
AC |
99 ms |
24216 KiB |
| test_22.txt |
AC |
124 ms |
24336 KiB |
| test_23.txt |
AC |
147 ms |
24192 KiB |
| test_24.txt |
AC |
97 ms |
24216 KiB |
| test_25.txt |
AC |
148 ms |
24392 KiB |
| test_26.txt |
AC |
147 ms |
24316 KiB |
| test_27.txt |
AC |
147 ms |
24216 KiB |
| test_28.txt |
AC |
152 ms |
24196 KiB |