标签:mda std 状态 cout ios break licensed 接下来 pac
2
1
1
2007-06-23-11:59
2007-06-23-12:00
1
#include<cstdio> #include<iostream> #include<algorithm> #include<map> #include<string> #include <math.h> #include<memory.h> #include<cstring> using namespace std; using namespace std; typedef long long ll; inline int read() { int x=0,f=1;char ch=getchar(); while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();} while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();} return x*f; } const int INF=0x3f3f3f3f; const int maxn=1e5+10; int n; int v[maxn]; int check(int x) //判断是否是闰年 { if(x%400==0)return true; if(x%100==0)return false; if(x%4==0)return true; return false; } int num[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; //平年每月的天数 ll ddd(int y,int m,int d) { y--; ll ret=365ll*y+y/4-y/100+y/400+d; for(int i=1;i<m;i++) { ret+=num[i]; if(i==2&&check(y+1))ret++; } return ret; } void inint(){ cin>>n; for(int i=1;i<=n;i++){ cin>>v[i]; } sort(v+1,v+n+1); } int main(){ inint(); char a[100]; int y1,y2,m1,m2,d1,d2,k1,k2,z1,z2; // char t1,t2,t3,t4 // scanf("%4d%c%2d%c%2d%c%2d%2d%c%2d",&y1,&t1,&m1,&t2,&d1,&t3,&k1,&t4,&z1); // cout<<"fjsf"<<endl; // getchar(); // scanf("%4d%c%2d%c%2d%c%2d%2d%c%2d",&y2,&t1,&m2,&t2,&d2,&t3,&k2,&t4,&z2); scanf("%s",a); y1=(a[0]-0)*1000+(a[1]-‘0‘)*100+(a[2]-‘0‘)*10+(a[3]-‘0‘); m1=(a[5]-‘0‘)*10+(a[6]-‘0‘); d1=(a[8]-‘0‘)*10+(a[9]-‘0‘); k1=(a[11]-‘0‘)*10+(a[12]-‘0‘); z1=(a[14]-‘0‘)*10+(a[15]-‘0‘); scanf("%s",a); y2=(a[0]-0)*1000+(a[1]-‘0‘)*100+(a[2]-‘0‘)*10+(a[3]-‘0‘); m2=(a[5]-‘0‘)*10+(a[6]-‘0‘); d2=(a[8]-‘0‘)*10+(a[9]-‘0‘); k2=(a[11]-‘0‘)*10+(a[12]-‘0‘); z2=(a[14]-‘0‘)*10+(a[15]-‘0‘); ll sum1=k1*60+z1; ll sum2=k2*60+z2; ll ans1=ddd(y1,m1,d1); ll ans2=ddd(y2,m2,d2); ll ans=ans2-ans1; ans=ans*24*60; ans=ans+(sum2-sum1); int p=0; for(int i=1;i<=n;i++){ if(ans>=v[i]){ ans-=v[i]; p++; } else{ break; } } cout<<p<<endl; }
标签:mda std 状态 cout ios break licensed 接下来 pac
原文地址:https://www.cnblogs.com/lipu123/p/12787703.html