165 字
1 分钟
题解:AT_abc443_c [ABC443C] Chokutter Addiction
AT_abc443_c [ABC443C] Chokutter Addiction 题解
思路
模拟。
显然逐秒模拟会 TLE。
考虑用一个变量 表示当前 chokutter 下一次打开的时间。
遍历每个 Aoki 经过的时间 ,如果当前的时间大于等于 ,那么从 到 这段时间是有效的观看时间,下次打开时间为 ,更新 变量。
最后,如果 ,说明从 到 之间 chokutter 一直处于打开状态,要把答案加上 。
时间复杂度为 。
Code
#include<bits/stdc++.h>using namespace std;#define int long longint n,t,s,ans,a[300005];signed main() { ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>n>>t; for (int i=1;i<=n;i++) cin>>a[i]; for (int i=1;i<=n;i++) if (a[i]>=s) ans+=a[i]-s,s=a[i]+100; if (s<t) ans+=t-s; cout<<ans; return 0;}题解:AT_abc443_c [ABC443C] Chokutter Addiction
https://banglee13.github.io/posts/atabc443c/分享文章
生成精美分享图或复制链接,与更多人分享本文。
继续阅读
最后更新于 ,距今已过 297 天
部分内容可能已过时