uva 11054
據說這叫掃描法,,,,感覺就是腦洞啊,,,,,反正從最左端開始,如果有酒就往后運,需要酒就運負的,就是相當于后面有酒了就運回來。。。
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; typedef long long ll; int n; int main() {while(~scanf("%d",&n)&&n){ll ans=0,last=0;for(int i=0;i<n;i++){int a;scanf("%d",&a);last+=a;ans+=abs(last);}printf("%lld\n",ans);}return 0; }?
轉載于:https://www.cnblogs.com/Wangwanxiang/p/6838287.html
總結
                            
                        - 上一篇: Matlab增加块注释
 - 下一篇: 微信小程序使用阿里巴巴矢量库图标