赛后总结
参加人数 |
提交总数 |
正确提交总数 |
错误提交总数 |
最高总分 |
最低总分 |
3 |
5 |
3 |
2 |
200 |
100 |
编号 |
题目名称 |
英文名称 |
数据点数目 |
最高得分 |
首位AC用户 |
统计 |
A |
表达式 |
expression |
10 |
100 |
yebh |
3 / 3 / 3 |
B |
表达式II |
exp |
jhhk77 |
2 / 2 / 2 |
C |
公路施工 |
build |
0 |
No user |
1 / 1 / 2 |
参考代码 (因为题目不难,所以就不写文字说明了,思路见注释)
#include <cstdio>
int mx(int a, int b) {
return a>b ? a : b;
} int main() {
int t, a, b, c;
scanf("%d", &t);
while (t--) {
scanf("%d %d %d", &a, &b, &c); int ans=a+b+c; ans=mx(ans, (a+b)*c);
ans=mx(ans, a+b*c);
ans=mx(ans, a*b+c);
ans=mx(ans, a*(b+c));
ans=mx(ans, a*b*c);
printf("%d\n", ans);
}
return 0;
}
#include <cstdio>
#include <cstring>
typedef long long ll;
const int N=20;
int a[N];
ll dp[N][N]; inline ll mx(ll a, ll b) {
return a>b ? a : b;
} ll dfs(int l, int r) { if (dp[l][r]!=-1) return dp[l][r]; if (l==r) return dp[l][r]=a[l]; ll tp=-1; for (int i=l; i<r; i++) {
tp=mx(tp, dfs(l, i)+dfs(i+1, r)); tp=mx(tp, dfs(l, i)*dfs(i+1, r)); }
return dp[l][r]=tp; }
int main() {
int t, n;
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
for (int i=0; i<n; i++)
scanf("%d", &a[i]); memset(dp, -1, sizeof(dp)); printf("%lld\n", dfs(0, n-1)); }
return 0;
}
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N=400010;
struct Build {
int f, id; ll p, len; } b[N];
ll dp[N]; bool cmp(Build u, Build v) {
if (u.p==v.p) return u.f<v.f;
return u.p<v.p;
} void in(ll &x) {
char c=getchar();
while (c<'0' || c>'9') c=getchar();
for (x=0; c>='0' && c<='9'; c=getchar())
x=x*10+c-'0';
} int main() {
int t;
scanf("%d", &t);
while (t--) {
ll n, x, y;
int k;
scanf("%lld %d", &n, &k);
for (int i=1; i<=k; i++) {
in(x), in(y);
b[i*2-1].f=0;
b[i*2-1].p=x;
b[i*2-1].id=i;
b[i*2-1].len=y-x+1;
b[i*2].f=1;
b[i*2].p=y;
b[i*2].id=i;
b[i*2].len=y-x+1;
} sort(b+1, b+2*k+1, cmp); memset(dp, 0, sizeof dp); ll maxl=0; for (int i=1; i<=2*k; i++) {
if (b[i].f==0) dp[b[i].id]=maxl+b[i].len; else
maxl=max(maxl, dp[b[i].id]); }
ll ans=0;
for (int i=1; i<=k; i++)
ans=max(ans, dp[i]); printf("%lld\n", ans); }
return 0;
}
- Solution Created By: wen
- Created Date:2020-10-29
共 4 条回复
全局没有超过适应范围,很好的题目。
膜拜yebh
不算太难,普及T3难度
最后一题非常有学习价值