Submission #385029

# Submission time Handle Problem Language Result Execution time Memory
385029 2021-04-03T02:14:55 Z zoooma13 Money (IZhO17_money) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    vector <int> a(n);
    vector <pair<int ,int>> sa;
    for(int&i : a){
        scanf("%d",&i);
        sa.push_back({i ,sa.size()});
    }
    sort(sa.begin() ,sa.end());
    for(int j=0,i=0; i<n; i++){
        j += (i && sa[i].first != sa[i-1].first);
        a[sa[i].second] = j;
    }
    //for(int&i : a) cout << i << ' '; cout << endl;

    int ans = 1 ,st = 0;
    for(int i=1; i<n; i++){
        if(a[i] < a[i-1]){
            st = i;
            ans++;
            continue;
        }
        bool bad = false;
        for(int j=0; j<i; j++)
            bad |= (a[st] < a[j] && a[j] < a[i]);
        ans += bad;
    }

    printf("%d\n",ans);
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
money.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |         scanf("%d",&i);
      |         ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -