题解 | #小美走公路#
小美走公路
https://www.nowcoder.com/practice/23a0696faab049c2b5beb480db684487
#include <bits/stdc++.h> using ll =long long int; using namespace std; int main() { int n; cin >> n; vector<ll> a(2 * n + 10,0); for (int i = 1; i <= n; i++) { cin>>a[i]; a[i+n]=a[i]; } for(int i=1;i<=2*n;i++){ a[i]+=a[i-1]; } int q,z; cin>>q>>z; if(q>z)swap(q,z); q--,z--; cout<<min(a[z]-a[q],a[q+n]-a[z]); }
瞎写的怎么跟题解一样,完全不懂啊