【队内胡策 11.3】 T1 T2
来源:互联网 发布:北京seo 编辑:程序博客网 时间:2024/04/30 12:08
再次把两个题写在一个博客里的原因是,这两道题简单。。
T1
暴力暴力暴力,不能再暴力的暴力,但是考试的时候打了很久,因为很多细节要处理
最后还是wa了一个点qwq,原因见代码44、45行少了一个特判,意思是,第二个日期的月份为2时,如果不是2月29,那么特判的闰年是不应该加上的qwq
代码:
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>typedef long long ll;using namespace std;char Day1[15],Day2[15],Co1[15],Co2[15];ll dd[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};ll n1,y1,d1,h1,m1,s1,n2,y2,d2,h2,m2,s2;ll cntn,cnty,cnts1,ans,cnts;int main(){ scanf("%s %s%s %s",Day1+1,Co1+1,Day2+1,Co2+1); for(ll i=1;i<=4;++i) n1=n1*10+(ll)(Day1[i]-'0'),n2=n2*10+(ll)(Day2[i]-'0'); y1=(Day1[6]-'0')*10+Day1[7]-'0'; y2=(Day2[6]-'0')*10+Day2[7]-'0'; d1=(Day1[9]-'0')*10+Day1[10]-'0'; d2=(Day2[9]-'0')*10+Day2[10]-'0'; h1=(Co1[1]-'0')*10+Co1[2]-'0'; h2=(Co2[1]-'0')*10+Co2[2]-'0'; m1=(Co1[4]-'0')*10+Co1[5]-'0'; m2=(Co2[4]-'0')*10+Co2[5]-'0'; s1=(Co1[7]-'0')*10+Co1[8]-'0'; s2=(Co2[7]-'0')*10+Co2[8]-'0'; for(ll i=n1+1;i<n2;++i) { cntn+=365; if(i%4==0) cntn++; } if(n1!=n2) { for(ll i=y1;i<=12;++i) { cnty+=dd[i]; if(i==y1) cnty-=d1; if(i==2&&n1%4==0) cnty++; } for(ll i=1;i<=y2;++i) { cnty+=dd[i]; if(i==y2) cnty-=dd[i]-d2; else if(i==2&&n2%4==0) cnty++; if(y2==2&&d2==29) cnty++; //44 45-->if(i==2&&n2%4==0) cnty++; } if(cnty) { cnty--; if(h1==h2&&m1==m2&&s1==s2) cnty++; } if(h1==h2&&m1==m2&&s1==s2) cnts=0; else { cnts1=h1*60*60+m1*60+s1; cnts=24*60*60-cnts1+h2*60*60+m2*60+s2; } } else { for(int i=y1+1;i<y2;++i) { cnty+=dd[i]; if(i==2&&n1%4==0) cnty++; } if(y1!=y2) { if(h1==h2&&m1==m2&&s1==s2) cnts=0; else { cnts1=h1*60*60+m1*60+s1; cnts=24*60*60-cnts1+h2*60*60+m2*60+s2; } cnty+=dd[y1]-d1+d2; if(n1%4==0&&y1==2) cnty++; } else { if(d1==d2) cnts=(h2-h1)*60*60-(m1-m2)*60-(s1-s2); else { if(h1==h2&&m1==m2&&s1==s2) cnts=0; else { cnts1=h1*60*60+m1*60+s1; cnts=24*60*60-cnts1+h2*60*60+m2*60+s2; } } cnty+=d2-d1; } if(cnty) { cnty--; if(h1==h2&&m1==m2&&s1==s2) cnty++; } } ans=(cntn+cnty)*24*60*60+cnts; ans*=1000; cout<<ans; return 0;}
T2
第一眼看是以前做的接水问题,仔细看不一样。考场上打完T1就没时间了,T2就没仔细想打了个60分的暴力qwq,其实这道题特别简单
小根堆里放每一个水龙头已经用过的时间,每次取出最小的,把下一个人加上
代码:
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<queue>#include<vector>using namespace std;const int maxn=100000+10;int n,m,ans;int t[maxn];priority_queue<int,vector<int>,greater<int> >q;int main(){ scanf("%d%d",&n,&m); for(int i=1;i<=n;++i) scanf("%d",&t[i]); for(int i=1;i<=m;++i) q.push(t[i]); int i=m+1; for(;i<=n;++i) { int x=q.top(); q.pop(); q.push(t[i]+x); } ans=q.top(); printf("%d",ans); return 0;}
阅读全文
0 0
- 【队内胡策 11.3】 T1 T2
- 【队内胡策 11.1】 T1 T2
- srm 526 T1 && T2
- srm527 T1 && T2
- sm 528 T1 && T2
- SRM 608 T1 && T2
- BeanUtils<T1, T2> beanToBean
- SRM 605 T1 T2 T3
- 磁共振中的T1, T2 和 T2*的原理和区别
- Func<T1, T2, TResult> 泛型委托
- 磁共振T1 T2 T1WI T2WI含义
- Dictionary<T1,T2>和Hashtable的异同
- 【JLOI2013】T1、T2、T3 Bzoj3190~3192
- SIP协议中的T1和T2
- NOIP 2013 day 2 t1 t2
- 51nod 1097 拼成最小的数 思维题 t1+t2<t2+t1
- FS-V1、FS-M1、FS-M2、FS-T1、FS-T2
- DateTime.Compare(t1,t2)比较两个日期大小
- opencv 链接共享库文件失败
- MySQL IFNULL()函数的用法
- 链表问题——删除链表的中间节点和a/b处的节点
- iptables nat及端口映射 【转】
- Camera原理
- 【队内胡策 11.3】 T1 T2
- 错误:Peer's certificate issuer has been marked as not trusted by the user
- TextToSpeech的使用
- 安装ftp服务器
- 对比数据库和DBF文件中的列名
- eclipse把项目发布到GitHub。操作笔记,自己备用
- POJ 3580. SuperMemo
- Oracle正则表达式中文标点符号的问题
- "undefined reference to" 问题解决方法