内容目录
这题送分题居然wa了
我仔仔细细地看了看题目……发现不慎把Yes 和No打萎了……
仅以为戒
#include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<cctype> #include<iostream> #include<functional> #include<algorithm> #include<string> using namespace std; #define MAXN (10000+10) int w[MAXN]; int a[MAXN]; string s; long long n,t; int main() { // freopen("read.in","r",stdin); // freopen("read.out","w",stdout); cin>>t>>n; for (int i=(int)('a');i<=(int)('z');i++) { cin>>w[i]; } // cout<<w[112]; for (int i=1;i<=n;i++) { cin>>s; a[i]=0; for (int j=0;j<s.length();j++) { s[j]=tolower(s[j]); // cout<<w[(tolower(s[i]))]<<' '; a[i] =a[i]+ w[s[j]]; // cout<<a[i]<<' '<<endl; } } sort(a+1,a+1+n); // for (int i=1;i<=n;i++) cout<<a[i]<<' '; for (int i=1;i<=n;i++) { t-=(long long)(a[i]); if (t<(long long)0) { cout<<"Non"; cout<<(i-1)<<endl; return 0; } } cout<<"Yesn"<<t<<endl; return 0; }