題目出處:http://codeforces.com/problemset/problem/884/Aios
題目大意:天天時間分兩部分,工做和學習,工做優先,閒暇讀書,問第幾天讀完學習
#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; }
簡單模擬,按順序把天天可讀書時間加和直到讀完spa