The Third Cup is Free

Panda and his friends were hiking in the forest. They came across a coffee bar inside a giant tree trunk.
Panda decided to treat everyone a cup of coffee and have some rest. Mr. Buck, the bartender greeted Panda and his animal friends with his antler. He proudly told them that his coffee is the best in the forest and this bar is a Michelin-starred bar, thats why the bar is called Starred Bucks.
There was a campaign running at the coffee bar: for every 3 cups of coffee, the cheapest one is FREE. After asking all his friends for their flavors, Panda wondered how much he need to pay.

Input
The first line of the input gives the number of test cases, T.
T test cases follow. Each test case consists of two lines. The first line contains one integer N, the number of cups to be bought.
The second line contains N integers
p1,p2,???,pNp1,p2,???,pN representing the prices of each cup of coffee.
Output
For each test case, output one line containing “Case #x: y”, where x is the test case number (starting from 1) and y is the least amount of money Panda need to pay.

limits


1 ≤ T ≤ 100.
1 ≤ N ≤ 105105 .
1 ≤ pi ≤ 1000.

Sample Input
2
3
1 2 3
5
10 20 30 20 20
Sample Output
Case #1: 5
Case #2: 80
题很简单,但一直用输入流,一直超时,记得要换标准输入啊。。
#include
#include
#include
using namespace std;
int a[100005];
bool cmp(int a, int b)
{
 return a > b;
}
int main()
{
 int T,cnt = 1,N,sum;
 cin >> T;
 while (T--)
 {
  scanf("%d", &N);
  for (int i = 1; i <=N; i++)
   scanf("%d", &a[i]);
  sort(a+1, a + N+1,cmp);
  sum = 0;
  for (int i = 1; i <=N; i++)
  {
   if (i % 3 == 0)
    continue;
    sum += a[i];
  }
  cout << "Case #" << cnt++ << ": "<<sum << endl;
 }
 return 0;
}

内容概要:本文介绍了基于条件生成对抗网络(Conditional Generative Adversarial Networks, CGAN)的可再生能源日前场景生成方法的复现研究,旨在通过Python代码实现对风电、光伏等可再生能源出力的不确定性进行高效建模与多场景生成。该方法利用历史数据作为条件输入,训练生成器与判别器网络,从而生成符合实际统计特性的高精度出力场景集,有效支撑电力系统调度、规划与风险评估等应用。文中详细阐述了CGAN的网络结构设计、损失函数构建、训练流程优化及生成场景的质量评价指标,并提供了完整的代码实现与案例分析,验证了其在捕捉时空相关性与概率分布方面的优越性。; 适合人群:具备一定深度学习与电力系统基础知识,从事新能源预测、电力系统优化调度、场景生成等相关方向的科研人员及研究生。; 使用场景及目标:①用于可再生能源出力不确定性建模,生成满足日前调度需求的典型场景集;②支撑含高比例新能源的电力系统随机优化、鲁棒调度与风险评估研究;③为学术研究提供可复现的CGAN应用场景与代码参考。; 阅读建议:建议读者结合提供的Python代码逐模块学习,重点关注数据预处理、模型搭建与训练细节,通过调整超参数和输入数据进行实验对比,深入理解CGAN在电力系统场景生成中的实际应用价值。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值