Codeforces Round #358 (Div. 2)
来源:互联网 发布:淘宝女装出入 编辑:程序博客网 时间:2024/05/12 02:43
682A - Alyona and Numbers
#include <bits/stdc++.h>#define met(a,b) memset(a,b,sizeof(a))#define inf (1<<28)#define mod 1000000007#define MAXN 100000 + 10#define MAXM 100000using namespace std;typedef long long LL;typedef long double LD;const double PI = acos(-1.0);const double eps = 1e-6;int n,m;int main(){ int i,j; LL ans = 0; cin>>n>>m; for(i=1;i<=n;i++) { int x = ((i/5) + 1) * 5 - i; if(m - x < 0) continue; ans += (m-x)/5 + 1;}cout<<ans<<endl;return 0;}
682B - Alyona and Mex
题目半天没看懂。。。
#include <bits/stdc++.h>#define met(a,b) memset(a,b,sizeof(a))#define inf (1<<28)#define mod 1000000007#define MAXN 100000 + 10#define MAXM 100000using namespace std;typedef long long LL;typedef long double LD;const double PI = acos(-1.0);const double eps = 1e-6;int n,m;int ary[MAXN];int main(){ int i,j; cin>>n; for(i=0;i<n;i++) scanf("%d",&ary[i]);sort(ary,ary+n);int ans = 0;for(i=0;i<n;i++){if(ary[i] > ans) ans++;}cout<<ans + 1<<endl;return 0;}
682C - Alyona and the Tree
建边,然后从1开始dfs
#include <bits/stdc++.h>#define met(a,b) memset(a,b,sizeof(a))#define inf (1<<28)#define mod 1000000007#define MAXN 100000 + 10#define MAXM 100000using namespace std;typedef long long LL;typedef long double LD;const double PI = acos(-1.0);const double eps = 1e-6;int n;int a[MAXN];vector<pair<int ,int > > v[MAXN];int dfs(int x,int fa,LL dis){if(dis > a[x]) return 0;LL ans = 1;for(int i=0;i<v[x].size();i++){if(v[x][i].first == fa) continue;ans += dfs(v[x][i].first,x,max(dis + v[x][i].second,0LL));//max是防止溢出 }return ans;}int main(){ int i,j; cin>>n; for(i=1;i<=n;i++) scanf("%d",&a[i]);int p,c;for(i=1;i<=n-1;i++){scanf("%d%d",&p,&c);//建立边 v[i+1].push_back({p,c});//从i+1开始排除v[1]这种情况 v[p].push_back({i+1,c});}int ans = dfs(1,0,0);cout<<n - ans<<endl;return 0;}
#include <bits/stdc++.h>#define met(a,b) memset(a,b,sizeof(a))#define inf (1<<28)#define mod 1000000007#define MAXN 1000 + 10#define MAXM 100000using namespace std;typedef long long LL;typedef long double LD;const double PI = acos(-1.0);const double eps = 1e-6;int n,m,k;char s1[MAXN],s2[MAXN];int dp[MAXN][MAXN][15][2]={0};int main(){ int i,j,t;cin>>n>>m>>k;cin>>s1+1>>s2+1;for(i=1;i<=n;i++){for(j=1;j<=m;j++){if(s1[i] == s2[j])for(t=1;t<=k;t++) dp[i][j][t][0] = max(dp[i-1][j-1][t][0],dp[i-1][j-1][t-1][1]) + 1 ; for(t = 1;t <= k;t++) dp[i][j][t][1] = max(max(max(dp[i-1][j-1][t][1],dp[i][j][t][0]),dp[i-1][j][t][1]),dp[i][j-1][t][1]);}}cout<<dp[n][m][k][1]<<endl;return 0;}
E题一点思路都没
0 0
- Codeforces Round #358 (Div. 2)
- Codeforces Round #358 (Div. 2)
- Codeforces Round #358 (Div. 2)
- Codeforces Round #358 (Div. 2)
- Codeforces Round #358 (Div. 2)
- Codeforces Round #358 (Div. 2)
- Codeforces Round #358 (Div. 2)
- Codeforces Round #358 (Div. 2)A~D
- Codeforces Round #358 (Div. 2) A
- Codeforces Round #358 (Div. 2) B
- Codeforces Round #358 (Div. 2) C
- Codeforces Round #358 (Div. 2) D
- Codeforces Round #358 (Div. 2) D dp
- Codeforces Round #358 (Div. 2) DP
- Codeforces Round #102 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #104 (Div. 2)
- 运动跟踪之CMT算法
- 2015年最热门编程语言岗位需求及薪资分析
- 信息安全与密码学-目录
- 设备环境DC
- html input file onchange事件失灵的解决方法
- Codeforces Round #358 (Div. 2)
- 设计四大独门秘诀
- css-元素水平、竖直居中
- 基本概念
- 使用IntelliJ IDEA创建Maven多模块项目
- 光学调焦和数字调焦
- 加载和刷新的在主界面里面
- 依赖注入setter,constructor
- 原来,它才是优化网站应该深度挖掘的内容