你能简述一下你的思路吗?
by sto_CJR_AK_IOI_orz @ 2024-01-29 20:52:55
@[sto_CJR_AK_IOI_orz](/user/439609) 因为血量是不能=0,所以初始值为1。然后因为整数是加的血量,负数是减的血量,所以用abs函数来求绝对值,因为整数是加的血量,所以用整数b[i]-b[i]*2= -b[i],然后再判断负数后面的整数
by Ghy_boy @ 2024-01-30 08:11:08
@[Ghy_boy](/user/1086459) 你看看我的代码:
```cpp
#include <iostream>
using namespace std;
const int N=1e6+10;
inline int read(){
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
inline void write(int x){
if(x<0){putchar('-');x=-x;}
if(x>9)write(x/10);
putchar(x%10+'0');
}
int n,ans=0x3f3f3f,now;
signed main(){
n=read();
for(int i=1;i<=n;i++){
now+=read();
ans=min(now,ans);
}
write(1-ans);
return 0;
}
```
by danlao @ 2024-02-13 21:26:40
没这么复杂吧
```
#include<bits/stdc++.h>
using namespace std;
int main( ){
int n;
cin>>n;
int a[n];
int s=0;
int min=0;
for(int i=3;i<=n;i++){
cin>>a[i];
s+=a[i];
if(s<min){
min=s;
}
}
cout<<min-min-min+1;
return 0;
}
by OIer_fish @ 2024-02-21 11:29:53