"Bzoj" "3850" ZCC Loves codefires

Source: Internet
Author: User
Tags type casting

Greedy, just like King NOIP2012 game, consider the location of the two adjacent problems, the other questions are not affected, and then look at the two questions order which is more excellent. Sort.

WA took one reason: although ans opened a long long, but in this sentence: ANS+=TIME*A[I].K, you still need to precede the time (int type) with (LL) for type casting.

1 /**************************************************************2 problem:38503 User:programmingape4 language:c++5 result:accepted6 time:64 Ms7 memory:2052 KB8 ****************************************************************/9  Ten //Bzoj 3850 One#include <cstdio> A#include <cstring> -#include <cstdlib> -#include <iostream> the#include <algorithm> - #defineRep (i,n) for (int i=0;i<n;++i) - #defineF (i,j,n) for (int i=j;i<=n;++i) - #defineD (i,j,n) for (int i=j;i>=n;--i) + using namespacestd; - Const intn=100086; +typedefLong LongLL; A structnode{ at     intt,k; -     BOOL operator< (Constnode& b)Const { -         returnt*k+ (t+b.t) *B.K < b.t*b.k+ (t+b.t) *K; -     } - }a[n]; -   in intMain () { - //freopen ("Input.txt", "R", stdin); to     intN; +scanf"%d",&n); -F (I,1, N) scanf ("%d",&a[i].t); theF (I,1, N) scanf ("%d",&a[i].k); *Sort (A +1, a+n+1); $LL time=0;Panax NotoginsengLL ans=0; -F (I,1, N) { thetime+=a[i].t; +ans+= (LL) a[i].k*Time ; A     } theprintf"%lld\n", ans); +     return 0; -}
View Code

"Bzoj" "3850" ZCC Loves codefires

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.