165 字
1 分钟
题解:AT_abc443_c [ABC443C] Chokutter Addiction

AT_abc443_c [ABC443C] Chokutter Addiction 题解#

题目传送门

思路#

模拟。

显然逐秒模拟会 TLE。

考虑用一个变量 ss 表示当前 chokutter 下一次打开的时间。

遍历每个 Aoki 经过的时间 AiA_i,如果当前的时间大于等于 ss,那么从 ss 到 AiA_i 这段时间是有效的观看时间,下次打开时间为 Ai+100A_i+100,更新 ss 变量。

最后,如果 s<Ts<T,说明从 ss 到 TT 之间 chokutter 一直处于打开状态,要把答案加上 T−sT-s。

时间复杂度为 O(N)O(N)。

Code#

#include<bits/stdc++.h>
using namespace std;
#define int long long
int 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/
作者
banglee
发布于
2026-02-01
许可协议
CC BY-NC-SA 4.0

分享文章

生成精美分享图或复制链接,与更多人分享本文。

继续阅读

沿着主题读

基于共同的标签与分类

换条路线

从其他文章中稳定抽取

最后更新于 ,距今已过 297 天

部分内容可能已过时