今天的题目出乎意料的“简单”
A 小蒜头爬山
这题简简单单,只要将相邻的两个数相减取绝对值,在用max即可
(代码如下)
include//yy
using namespace std;
long a[100000005],b[500005];
int main() {
freopen("mountain.in","r",stdin);
freopen("mountain.out","w",stdout);
int i,n,c=0,d;
cin>>n;
for(i=1;i>a[i];
}
for(i=1;i<=n;i++){
if(i!=n){
b[i]=a[i]-a[i+1];
if(b[i]<=0)b[i]=-b[i];
else b[i]=b[i];
d=b[i];
c=max(c,d);
}
}
cout<<c;
return 0;
}
B 小蒜头的矩阵
看到这题的时候原以为很简单,但又又出乎意料,思路错了,没成想得了个0,但下午就改出来了(错了就不放了)
C 小蒜头的时间
这题使我重新认识了第三题的地位,这么简单,但依旧有人没写出来,这让我开心(daimaruxia)
include//yy
using namespace std;
long q[1000005],w[1000005],t[1000005],p[1000005];
int main() {
freopen("time.in","r",stdin);
freopen("time.out","w",stdout);
long long i,m,s=0,f=0;
cin>>m;
for(i=1;i>q[i];
if(q[i]1){
cin>>t[i]>>w[i];
}
if(q[i]2){
cin>>p[i];
}
}
for(i=1;i<=m;i++){
if(q[i]1){
s=s+t[i];
f=f+w[i];
cout<<f<<endl;
continue;
}
else if(q[i]2){
if(i1){
if(t[i]s-p[i]){
cout<<f<<endl;
continue;
}
else {
cout<<0<1){
if(t[i-1]s-p[i]){
cout<<f<<endl;
continue;
}
else{
cout<<0<<endl;
f=0;
continue;
}
}
}
}
return 0;
}
D 小蒜头的学生