結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー |
|
提出日時 | 2020-05-30 09:28:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 462 bytes |
コンパイル時間 | 2,817 ms |
コンパイル使用メモリ | 193,452 KB |
最終ジャッジ日時 | 2025-01-10 19:13:58 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:8:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | int gx,gy,n,f; scanf("%d%d%d%d",&gx,&gy,&n,&f); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:10:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | rep(i,n) scanf("%d%d%d",&dx[i],&dy[i],&c[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>#define rep(i,n) for(int i=0;i<(n);i++)using namespace std;int main(){int gx,gy,n,f; scanf("%d%d%d%d",&gx,&gy,&n,&f);vector<int> dx(n),dy(n),c(n);rep(i,n) scanf("%d%d%d",&dx[i],&dy[i],&c[i]);int dp[101][101];rep(y,gy+1) rep(x,gx+1) dp[y][x]=f*(x+y);rep(i,n){for(int y=gy;y>=dy[i];y--) for(int x=gx;x>=dx[i];x--) {dp[y][x]=min(dp[y][x],dp[y-dy[i]][x-dx[i]]+c[i]);}}printf("%d\n",dp[gy][gx]);return 0;}