题目出处:http://codeforces.com/problemset/problem/884/A
题目大意:每天时间分两部分,工作和学习,工作优先,闲暇读书,问第几天读完
#include<iostream> #include<stdlib.h> using namespace std; //简单的模拟 int main(){ int n,t; cin>>n>>t; int count =0,ans; const int day = 86400; int *a = (int*) malloc (n*sizeof(int)); int flag=1; for(int i=0;i<n;i++){ cin>>a[i]; count += (day - a[i]); //cout<<count<<endl; if(flag && count >= t){ flag=0; ans = ++i; } } cout<<ans<<endl; return 0; }
简单模拟,按顺序把每天可读书时间加和直到读完