[Nonsense] HDU 5122 K. Bro Sorting, hdu5122

Source: Internet
Author: User

[Nonsense] HDU 5122 K. Bro Sorting, hdu5122

Click Open Link

Train of Thought: for each number, as long as the number behind it is smaller than it, it needs to be changed.

So we can calculate it against it .. (Minimum value recorded at the same time)

#include <cstdio>#include <cstring>#include <cstdlib>#include <string>#include <iostream>#include <algorithm>#include <sstream>#include <cmath>using namespace std;#include <queue>#include <stack>#include <set>#include <vector>#include <deque>#include <map>#define cler(arr, val)    memset(arr, val, sizeof(arr))#pragma comment(linker, "/STACK:102400000,102400000")typedef long long  LL;const int MAXN = 230+1;const int MAXM = 140000;const int INF = 0x3f3f3f3f;const int mod = 1000000007;int a[10000100];int main(){#ifndef ONLINE_JUDGE       freopen("in.txt", "r", stdin);   //  freopen("out.txt", "w", stdout);#endif    int t,n,cas=1;    cin>>t;    while(t--)    {        cin>>n;        for(int i=0;i<n;i++)            scanf("%d",&a[i]);        int maxx=999999999,sum=0;        for(int i=n-1;i>=0;i--)        {            if(maxx<a[i])                sum++;            else maxx=a[i];        }        printf("Case #%d: ",cas++);        cout<<sum<<endl;    }}



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.