wangcm @ 2024-10-13 14:52:49
#include<bits/stdc++.h>
using namespace std;
int del(string n,vector<int>&costs)
{
int length=n.size();
vector<int>dp(length+1,0);
for(int i=1;i<=length;i++){
int dg=n[i-1]-'1';
dp[i]=dp[i-1]+costs[dg];
dp[i]=min(dp[i],dp[i-1]+stoi(n.substr(i-1)));
}
return dp[length];
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int c,t;
cin>>c>>t;
while(t--){
string n;
cin>>n;
vector<int>costs(9);
for (int i=0;i<9;i++){
cin>>costs[i];
}
int res=del(n,costs);
cout<<res<<endl;
}
return 0;
}
显示stoi报错了……
by Estrella_Explore @ 2024-10-13 14:55:40
g++ 14.2.1 20240910
没有关于 stoi()
的报错或警告
by wangcm @ 2024-10-13 15:01:14
@Estrella_Explore 可是……
by sunxuanyu @ 2024-10-13 15:03:55
开c++11了吗?
by wangcm @ 2024-10-13 15:08:13
@sunxuanyu 开了也不行
by sunxuanyu @ 2024-10-13 15:11:19
gcc版本?
by wangcm @ 2024-10-13 15:12:16
@sunxuanyu TDM-GCC 4.9.2
by Estrella_Explore @ 2024-10-13 15:13:58
@wangcm
g++ 14.2.1
开 --std=c++14
也没问题,升级一下 g++
版本吧,你那才 4.9.2
……
by wangcm @ 2024-10-13 19:57:42
@Estrella_Explore 终于没问题了
版本:TDM-GCC 9.2.0