結果
| 問題 |
No.974 最後の日までに
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-01-18 00:56:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,418 bytes |
| コンパイル時間 | 438 ms |
| コンパイル使用メモリ | 57,836 KB |
| 最終ジャッジ日時 | 2025-01-08 19:47:45 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 48 MLE * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%d", &w);
| ~~~~~^~~~~~~~~~
main.cpp:17:35: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | for(int i = 0; i < w; i++) scanf("%lld%lld%lld", A+i, B+i, C+i);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <vector>
#include <algorithm>
int w;
long long int A[100], B[100], C[100];
struct S {
long long int money;
long long int love;
};
std::vector<S> states0, states1, tmp;
int main(){
scanf("%d", &w);
for(int i = 0; i < w; i++) scanf("%lld%lld%lld", A+i, B+i, C+i);
states0.emplace_back(S({0, 0}));
for(int i = 0; i < w; i++){
for(auto it0 = states0.begin(), it1 = states1.begin(); ;){
if(it0 == states0.end()){ for(; it1 != states1.end(); ++it1){ tmp.emplace_back(S({it1->money - C[i], it1->love + B[i]})); } break;}
else if(it1 == states1.end()){ for(; it0 != states0.end(); ++it0){ tmp.emplace_back(S({it0->money + A[i], it0->love})); } break;}
else if(it0->money + A[i] >= it1->money - C[i] && it0->love >= it1->love + B[i]) ++it1;
else if(it0->money + A[i] <= it1->money - C[i] && it0->love <= it1->love + B[i]) ++it0;
else if(it0->money + A[i] <= it1->money - C[i]) tmp.emplace_back(S({it0->money + A[i], it0->love})), ++it0;
else tmp.emplace_back(S({it1->money - C[i], it1->love + B[i]})), ++it1;
}
states0.swap(states1);
states0.swap(tmp);
tmp.clear();
/*
for(auto &s: states0) printf("(%lld %lld) ", s.money, s.love);
puts("");
std::fflush(stdout);
*/
}
long long int ans = 0;
for(auto &s: states0){
if(s.money >= 0){
ans = s.love;
break;
}
}
printf("%lld\n", ans);
return 0;
}