Submission #385027

# Submission time Handle Problem Language Result Execution time Memory
385027 2021-04-03T01:56:21 Z zoooma13 Money (IZhO17_money) C++14
0 / 100
2 ms 384 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 i=0; i<n; i++)
        a[sa[i].second] = i;

    int ans = 1;
    for(int i=1; i<n; i++){
        if(a[i] < a[i-1]){
            ans++;
            continue;
        }
        bool bad = false;
        for(int j=0; j<i; j++)
            bad |= (a[i-1] < 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 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -