DP ZOJ 3872 Beauty of Array

Source: Internet
Author: User

Topic Portal

1 /*2 DP:DP represents the and of the sub-sequences containing x before the current input x,3 The summation method is to find the sub-sequences within the interval of the previous occurrence of X (A[x]);4 sum represents all the sum of the current input before x;5 A[x] represents the ID;6 Detailed Explanation:http://blog.csdn.net/u013050857/article/details/452855157 */8#include <cstdio>9#include <algorithm>Ten#include <cmath> One#include <iostream> A#include <cstring> -#include <string> -#include <map> the#include <Set> - using namespacestd; -  - Const intMAXN = 1e5 +Ten; + Const intINF =0x3f3f3f3f; - intA[MAXN]; +  A intMainvoid)//ZOJ 3872 Beauty of Array at { -     //freopen ("d.in", "R", stdin); -  -     intt, N; -scanf ("%d", &t); -      while(t--) in     { -Memset (A,0,sizeof(a)); toscanf ("%d", &n); +  -         intXLong LongDP =0, sum =0; the          for(intI=1; i<=n; ++i) *         { $scanf ("%d", &x);Panax NotoginsengDP = (I-a[x]) * x +DP; -Sum + =DP; theA[X] =i; +         } A  theprintf ("%lld\n", sum); +     } -  $  $     return 0; -}

DP ZOJ 3872 Beauty of Array

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.