`
阿尔萨斯
  • 浏览: 4109894 次
社区版块
存档分类
最新评论

Codeforces 439A, the Singer and Churu, the Joker(水题)

 
阅读更多

题目链接:Codeforces 439A Devu, the Singer and Churu, the Joker


题目大意:Devu是一个歌唱家,Churu是个小丑,他们被共同邀请参加一个表演秀,Devu准备了n首歌曲,每首歌曲演唱需要ti时间,Churu负责讲笑话,每个笑话5分钟。现在节目的总时长为d,Devu每两首歌之间要休息10分钟,表演的总时间不能超过d,Churu非常亢奋,问Churu最多可以讲多少个笑话,前提是Devu必须唱完所有的歌,因为所有的人都是来听Devu唱歌的,否则输出-1。


解题思路:两首歌中间的10分钟肯定个Churu讲两个笑话,这样算时间有剩就都给Churu讲笑话用。如果这样都不够用那么久输出-1。


#include <cstdio>
#include <cstring>

int main () {
    int n, d, t, s = 0;

    scanf("%d%d", &n, &d);
    for (int i = 0; i < n; i++) {
        scanf("%d", &t);
        s += t;
    }

    s += (n - 1) * 10;

    if (s > d)
        printf("-1\n");
    else {
        int tmp = d - s;
        printf("%d\n", n * 2 - 2 + tmp / 5);
    }
    return 0;
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics