本文共 1479 字,大约阅读时间需要 4 分钟。
Mean:
略。
analyse:
水题。
Time complexity: O(n)
Source code:
// Memory Time// 1347K 0MS// by : crazyacking// 2015-03-29-12.08#include#include #include #include #include #include #include #include #include #include #include #include #define MAXN 1000010#define LL long longusing namespace std;int main(){ ios_base::sync_with_stdio(false); cin.tie(0);// freopen("C:\\Users\\Devin\\Desktop\\cin.cpp","r",stdin);// freopen("C:\\Users\\Devin\\Desktop\\cout.cpp","w",stdout); string a,b,c; while(cin>>a>>b>>c) { bool flag=true; int len=a.length(); int aa[26],bb[26],cc[26],dd[26]; memset(aa,0,sizeof aa),memset(bb,0,sizeof bb),memset(cc,0,sizeof cc),memset(dd,0,sizeof dd); for(int i=0;i 0) { sum+=dd[i]; if(dd[i]>bb[i]) { flag=false; break; } } } if(!flag) { puts("NO"); continue; } int half=len/2; sum=0; for(int i=0;i<26;++i) { if(dd[i]<=0) { sum+=min(bb[i],cc[i]); } else { sum+=min(bb[i],cc[i]); } } if(sum>=half) { puts("YES"); continue; } else { puts("NO"); continue; } } return 0;}/**//************************************************************** Problem: 1550 User: crazyacking Language: C++ Result: Accepted Time:8 ms Memory:1976 kb****************************************************************/
转载于:https://www.cnblogs.com/crazyacking/p/4376599.html