Triple Attack 题解
直接暴力显然不可行。
我们容易发现,变量
有些细节。
Code
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace std;
// using namespace __gnu_pbds;
// tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> tr;//从小到大
// int findnum(int k){auto it=tr.find_by_order(k-1);return ((it!=tr.end())?(*it):1e9+7);}//查元素
// int findrank(int x){return tr.order_of_key(x)+1;}//查排名
static char buf[100000], *pa = buf, *pd = buf;
#define gc pa == pd && (pd = (pa = buf) + fread(buf, 1, 100000, stdin), pa == pd) ? EOF : *pa++
inline int read()
{
int w = 1, s = 0; char ch = gc;
while(!isdigit(ch)){if(ch=='-')w=-1;ch=gc;}
while(isdigit(ch)){s=s*10+(ch-'0');ch=gc;}
return w*s;
}
const int mod=998244353;
const int maxn=1e6+10;
const int inf=1e9+7;
int n,m,a[maxn],b[maxn];
string s,t;
int ans,sum;
signed main()
{
#ifdef Lydic
freopen(".in","r",stdin);
freopen(".out","w",stdout);
// #else
// freopen("direct.in","r",stdin);
// freopen("direct.out","w",stdout);
#endif
cin>>n;
for(int i=1;i<=n;i++)a[i]=read();
int t=1;
for(int i=1;i<=n;i++)
{
if(t%3==1)
{
a[i]--;t++;
if(a[i]<=0)continue;
a[i]--;t++;
if(a[i]<=0)continue;
}
else if(t%3==2)
{
a[i]--;t++;
if(a[i]<=0)continue;
}
// cout<<a[i]<<' '<<t<<endl;
int d=a[i]/5,k=a[i]%5;
if(k==0)
{
t+=d*3;
continue;
}
if(k<=3)t++;
else if(k==4)t+=2;
t+=d*3;
}
cout<<t-1;
return 0;
}
分类:
题解合集
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】