結果
| 問題 |
No.798 コレクション
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-15 22:29:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 555 bytes |
| コンパイル時間 | 740 ms |
| コンパイル使用メモリ | 77,584 KB |
| 実行使用メモリ | 8,808 KB |
| 最終ジャッジ日時 | 2024-07-01 21:09:43 |
| 合計ジャッジ時間 | 2,020 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 7 RE * 2 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
8 | main()
| ^~~~
main.cpp: In function 'int main()':
main.cpp:18:61: warning: iteration 700 invokes undefined behavior [-Waggressive-loop-optimizations]
18 | for(int i=0;i<=n;i++)for(int j=0;j<=700;j++)dp[i][j]=1e9;
| ~~~~~~~~^~~~
main.cpp:18:43: note: within this loop
18 | for(int i=0;i<=n;i++)for(int j=0;j<=700;j++)dp[i][j]=1e9;
| ~^~~~~
ソースコード
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n;
vector<pair<int,int> >a;
int dp[2001][700];
main()
{
cin>>n;
for(int i=0;i<n;i++)
{
int u,v;cin>>u>>v;
a.push_back(make_pair(v,u));
}
sort(a.begin(),a.end());
reverse(a.begin(),a.end());
for(int i=0;i<=n;i++)for(int j=0;j<=700;j++)dp[i][j]=1e9;
dp[0][0]=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<=n/3;j++)
{
dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]);
dp[i+1][j]=min(dp[i+1][j],dp[i][j]+a[i].second+a[i].first*(i-j));
}
}
cout<<dp[n][n/3]<<endl;
}