Helvetic Coding Contest 2017 online mirror (teams allowed, unrated)
As it's the first of April, Heidi is suspecting that the news she reads today are fake, and she does not want to look silly in front of all the contestants. She knows that a newspiece is fake if it contains heidi as a subsequence. Help Heidi assess whether the given piece is true, but please be discreet about it...
The first and only line of input contains a single nonempty string s of length at most 1000 composed of lowercase letters (a-z).
Output YES if the string s contains heidi as a subsequence and NO otherwise.
abcheaibcdi
YES
hiedi
NO
A string s contains another string p as a subsequence if it is possible to delete some characters from s and obtain p.
看下给你的字符串是否存在“heidi”
#include<stdio.h> char s[]="heidi",st[100005]; int n,num=0; int main() { scanf("%s",st+1); for(int i=1;st[i];++i) { if(st[i]==s[num]) ++num; if(num==5) return 0*puts("YES"); } puts("NO"); return 0; }
The marmots have prepared a very easy problem for this year's HC2 – this one. It involves numbers n, k and a sequence of npositive integers a1, a2, ..., an. They also came up with a beautiful and riveting story for the problem statement. It explains what the input means, what the program should output, and it also reads like a good criminal.
However I, Heidi, will have none of that. As my joke for today, I am removing the story from the statement and replacing it with these two unhelpful paragraphs. Now solve the problem, fools!
The first line of the input contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 2200). The second line contains nspace-separated integers a1, ..., an (1 ≤ ai ≤ 104).
Output one number.
8 5
1 1 1 1 1 1 1 1
5
10 3
16 8 2 4 512 256 32 128 64 1
7
5 1
20 10 50 30 46
10
6 6
6 6 6 6 6 6
36
1 1
100
100
我在做这些水题真的好么?只当练英语了,n个数选k个最小的和,不开心的时候就A水题?
#include <bits/stdc++.h> int a[2205]; using namespace std; int main() { int n,k; scanf("%d%d",&n,&k); for(int i=0;i<n;i++) scanf("%d",&a[i]); sort(a,a+n); int s=0; for(int i=0;i<k;i++) s+=a[i]; printf("%d",s); return 0; }
本文来自博客园,作者:暴力都不会的蒟蒻,转载请注明原文链接:https://www.cnblogs.com/BobHuang/p/6921302.html