比赛 |
SBOI2022暑假快乐赛① |
评测结果 |
AWWWWWWWWW |
题目名称 |
士兵放假了 |
最终得分 |
10 |
用户昵称 |
yrtiop |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2022-06-25 10:33:11 |
显示代码纯文本
#include <bits/stdc++.h>
#define pb emplace_back
using namespace std;
const int maxn = 1e3 + 5;
double m,k,sum1,sum2,sum3,sum4;
int n;
int main() {
freopen("holiday_and_angryF.in","r",stdin);
freopen("holiday_and_angryF.out","w",stdout);
scanf("%d%lf%lf",&n,&m,&k);
sum1 = sum2 = 0;
sum3 = sum4 = 1;
for(int i = 1;i <= n;++ i) {
double x;
char c;
scanf("%lf %c",&x,&c);
if(c == '+') {
sum1 += x;
}
else if(c == '-') {
sum2 += x;
}
else if(c == '*') {
sum3 *= x;
k *= x;
}
else if(c == '/') {
sum4 *= x;
k /= x;
}
}
double cost1 = (sum1 * sum3 - sum2) / sum4;
double cost2 = sum1 * sum3 - sum2 * sum3 / sum4;
k += max(cost1 , cost2);
if(k >= m) {
printf("YES\n%.0lf",k - 0.49);
}
else puts("NO");
fclose(stdin);
fclose(stdout);
return 0;
}