Problem:
How is this solution actually working for this problem?
In short:
cin>>n;
for(int i=1;i<=n;i++){
res+=min(i,n-i+1);
}
cout<<res<<endl;
Solution:
Problem:
How is this solution actually working for this problem?
In short:
cin>>n;
for(int i=1;i<=n;i++){
res+=min(i,n-i+1);
}
cout<<res<<endl;
Solution: