码题集OJ-小码哥和假期堵车 (matiji.net)
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, pass;
const int daytime=1440;
const int N=110;
int a[N];
signed main()
{
cin.tie(0)->sync_with_stdio(0);
cin>>n>>pass;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
for(int i=1;i<=n;i++)
{
int t=daytime-a[i];
if(t>=60)
{
if(pass-t<=0)
{
cout<<i;
break;
}
else
{
pass-=t;
if(pass<=0)
{
cout<<i<<endl;
break;
}
}
}
}
return 0;
}

二刷
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,t,cnt=1,temp,temp2;
const int DAY=1440;
const int N=1e2+10;
int a[N];
signed main()
{
cin.tie(nullptr)->sync_with_stdio(false);
int n,t;cin>>n>>t;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n;i++)
{
int T=DAY-a[i];
if(T>=60)
{
temp=T-t;
if(temp>=0)
{
cout<<cnt<<endl;
break;
}
else
{
temp2=t-T;
t=temp2;
}
}
cnt++;
}
return 0;
}
