【解题报告】AtCoder ABC115 (附英文题目)

------------------------------迟到的AK----------------------------------

A - Christmas Eve Eve Eve


Time limit : 2sec / Memory limit : 1024MB

Score : 100 points

Problem Statement

In some other world, today is December D-th.

Write a program that prints Christmas if D=25, Christmas Eve if D=24, Christmas Eve Eve if D=23 and Christmas Eve Eve Eve if D=22.

Constraints

  • 22≤D≤25
  • D is an integer.

签到题1,考察if语句的用法。。。

 1 #include <iostream>
 2 int main()
 3 {
 4     int n; std::cin >> n;
 5     if (n == 25) puts("Christmas");
 6     if (n == 24) puts("Christmas Eve");
 7     if (n == 23) puts("Christmas Eve Eve");
 8     if (n == 22) puts("Christmas Eve Eve Eve");
 9     return 0;
10 }

 

B - Christmas Eve Eve


Time limit : 2sec / Memory limit : 1024MB

Score : 200 points

Problem Statement

In some other world, today is the day before Christmas Eve.

Mr. Takaha is buying N items at a department store. The regular price of the i-th item (1≤iN) is pi yen (the currency of Japan).

He has a discount coupon, and can buy one item with the highest price for half the regular price. The remaining N−1 items cost their regular prices. What is the total amount he will pay?

Constraints

  • 2≤N≤10
  • 100≤pi≤10000
  • pi is an even number.

签到题2,考察for语句的用法。。。

1 #include <iostream>
2 int main()
3 {
4     int n, x, si = 0, mi = -1; std::cin >> n;
5     for (int i = 1; i <= n; ++i) 
6         std::cin >> x, si += x, mi = std::max(mi, x);
7     std::cout << si - (mi >> 1);
8     return 0;
9 }

 

C - Christmas Eve


Time limit時間制限 : 2sec / Memory limitメモリ制限 : 1024MB

Score : 300 points

Problem Statement

In some other world, today is Christmas Eve.

There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1≤iN) is hi meters.

He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.

More specifically, let the height of the tallest decorated tree be hmax meters, and the height of the shortest decorated tree be hmin meters. The smaller the value hmaxhmin is, the better. What is the minimum possible value of hmaxhmin?

Constraints

  • 2≤K<N≤105
  • 1≤hi≤109
  • hi is an integer.

签到题3,考察sort函数的用法。。。

 1 #include <iostream>
 2 #include <algorithm>
 3 int h[101010];
 4 int main()
 5 {
 6     int n, mi = 2e9 + 1, k; std::cin >> n >> k;
 7     for (int i = 1; i <= n; ++i) std::cin >> h[i];
 8     std::sort(h + 1, h + n + 1);
 9     for (int i = k; i <= n; ++i) mi = std::min(mi, h[i] - h[i - k + 1]);
10     std::cout << mi;
11     return 0;
12 }

D - Christmas


Time limit時間制限 : 2sec / Memory limitメモリ制限 : 1024MB

Score : 400 points

Problem Statement

In some other world, today is Christmas.

Mr. Takaha decides to make a multi-dimensional burger in his party. A level-L burger (L is an integer greater than or equal to 0) is the following thing:

  • A level-0 burger is a patty.
  • A level-L burger (L≥1) is a bun, a level-(L−1) burger, a patty, another level-(L−1) burger and another bun, stacked vertically in this order from the bottom.

For example, a level-1 burger and a level-2 burger look like BPPPB and BBPPPBPBPPPBB (rotated 90 degrees), where B and P stands for a bun and a patty.

The burger Mr. Takaha will make is a level-N burger. Lunlun the Dachshund will eat X layers from the bottom of this burger (a layer is a patty or a bun). How many patties will she eat?

Constraints

  • 1≤N≤50
  • 1≤X≤( the total number of layers in a level-N burger )
  • N and X are integers.
 1 #include <iostream>
 2 #include <algorithm>
 3 
 4 long long b[60], h[60], n, r, ans;
 5 
 6 void solve(int now)
 7 {
 8     if (r <= 0) return;
 9     if (!now) { --r, ++ans; return; }
10     if (r >= h[now]) { r -= h[now], ans += b[now]; return; } 
11     --r; if (r > 0) solve(now - 1);
12     if (r > 0) ++ans, --r;
13     --r; if (r > 0) solve(now - 1);
14 }
15 
16 int main()
17 {
18     scanf("%lld%lld", &n, &r);
19     h[0] = 1, b[0] = 1;
20     for (int i = 1; i <= 50; ++i) h[i] = (h[i - 1] << 1) + 3, b[i] = 1 + (b[i - 1] << 1);
21     solve(n); std::cout << ans;
22     return 0;
23 }

太简单辣。。。。。。。。

 

 

转载于:https://www.cnblogs.com/yanyiming10243247/p/10091874.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值