結果
| 問題 |
No.37 遊園地のアトラクション
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-10-29 16:39:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 525 bytes |
| コンパイル時間 | 738 ms |
| コンパイル使用メモリ | 44,800 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-13 04:36:55 |
| 合計ジャッジ時間 | 1,440 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 4 |
| other | WA * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%d%d",&T,&N);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:9:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | for(int i=0;i<N;i++)scanf("%d",&v[i].first);
| ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:10:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | for(int i=0;i<N;i++)scanf("%d",&v[i].second);
| ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(){
int T,N,S=0;
scanf("%d%d",&T,&N);
vector<pair<int,int> >v(N);
for(int i=0;i<N;i++)scanf("%d",&v[i].first);
for(int i=0;i<N;i++)scanf("%d",&v[i].second);
for(;N--;){
int x=v[N].first,y=v[N].second;
for(y/=2;y;y/=2)v.push_back(make_pair(x,y));
}
vector<int>bag(T+1);
for(int i=0;i<v.size();i++)for(int j=T;j>=v[i].first;j--)bag[j]=max(bag[j],bag[j-v[i].first]+v[i].second);
int r=0;
for(int i=0;i<=T;i++)r=max(r,bag[i]);
}