day2模拟赛总结
来源:互联网 发布:犀牛软件界面 编辑:程序博客网 时间:2024/05/22 14:44
今天上午的题好难,基本上也就能得个几十分,不过rqy稍微启发了一下我就130了,第三题的暴力都难打。下午题比较水,第一题可是第一次想的时候还是想偏了,话说这么弱,一等奖都不知道有没有,好悲伤...真的希望当一名文化课和信息学兼顾的oier...
dayt1 dp,关键是想一个贪心...然后dp,代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=55;
int n,c[maxn],h[maxn],t,dp[maxn][maxn];
inline int read(){
int num=0,f=1; char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-') f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9') num=num*10+ch-'0',ch=getchar();
return num*f;
}
struct node{
int c,h;
}s[maxn];
bool cmp(node a,node b){
return a.h<b.h;
}
int main(){
freopen("meet.in","r",stdin);
freopen("meet.out","w",stdout);
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&s[i].c);
for(int i=1;i<=n;i++) scanf("%d",&s[i].h);
scanf("%d",&t);
sort(s+1,s+1+n,cmp);
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
dp[i][j]=100000000;
}
}
for(int i=1;i<=n;i++){
dp[i][1]=s[i].c;
}
for(int i=1;i<=n;i++){
for(int j=2;j<=i;j++){
for(int k=1;k<=i-1;k++){
dp[i][j]=min(dp[i][j],dp[k][j-1]+abs(s[i].h-s[k].h)+s[i].c);
}
}
}
int ans=-1,ans1=100000000;
for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
if(dp[i][j]<=t){
ans=max(ans,j);
}
}
}
/*for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
cout<<dp[i][j]<<' ';
}
cout<<endl;
}*/
cout<<ans<<endl;
//fclose(stdin);
//fclose(stdout);
return 0;
}
ac!
第二题主要是考虑 设 a1<a2<a3<......an; b1<b2<.....bn;
b1=a1+a2; b2=a1+a3; b3不确定,需要枚举,枚举自后用set实现对b数组的删除(平衡树)。没写...
第三题是道数据结构题..链表...
六十分做法...把%p的所有值处理出来...然后...二分...一百分在六十分基础上分块,懒得搞一百分
暴力代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
int a[maxn],n,m,s[maxn];
inline int read(){
int num=0,f=1; char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-') f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9') num=num*10+ch-'0',ch=getchar();
return num*f;
}
int main(){
freopen("light.in","r",stdin);
freopen("light.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
int l,r,p,v,num;
for(int i=1;i<=m;i++){
scanf("%d%d%d%d",&l,&r,&p,&v);
num=0;
for(int j=l;j<=r;j++){
if(a[j]%p==v) ++num;
}
cout<<num<<endl;
}
fclose(stdin);
fclose(stdout);
return 0;
}
顺便水了一下洛谷八连测r6
t1 70分前缀和 t2 20分暴力 t3 30分暴力
- day2模拟赛总结
- CQOI2016 day2 模拟赛总结
- NOIP2014 Day2 模拟赛赛后总结&题解
- CH Round #55 - Streaming #6 (NOIP模拟赛day2)总结
- 2- noip模拟赛 DAY2
- GDOI第四轮模拟day2总结
- 2014.08.10 CH Round#49-Streaming#4(NOIP模拟赛Day2) 总结
- CH Round #49 - Streaming #4 (NOIP模拟赛Day2)(总结)
- contesthunter NOIP模拟赛Day2 8.10
- 模拟赛day2 2014 10 26
- 山东多校联合模拟赛 Day2
- 省选模拟赛[HEOI2012] Day2
- 省选模拟赛[SHOI2017] Day2
- 【20150905】NOIP模拟套题01 day2 题解 & 总结
- 【20150915】NOIP模拟套题02 day2 题解 & 总结
- 洛谷 NOIP 模拟 DAY2
- noip膜你赛day2 总结
- CH Round #49 - Streaming #4 (NOIP模拟赛Day2)
- Linux学习总结
- bzoj1226 [SDOI2009]学校食堂Dining 状压DP
- kafka Consumer详解
- [java之list比较]
- 【BigHereo 47】---DataStructure---数据结构之图(五)
- day2模拟赛总结
- db2重命名表
- C/C++:Linux时间函数以及基本概念
- 类和对象
- C++ mutable关键字
- 基于SSM+redis+solr的java校园论坛系统的设计与实现
- 二元一次方程求根
- ROS学习第二弹(Package/Nodes/Topic)
- 排序算法——稳定性、比较次数、交换次数