Submission #331644

# Submission time Handle Problem Language Result Execution time Memory
331644 2020-11-29T11:14:49 Z vitkishloh228 Money (IZhO17_money) C++14
0 / 100
0 ms 364 KB
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    vector<int> q = a;
    sort(q.begin(), q.end());
    vector<int> used(n);
    for (int i = 0; i < n; ++i) {
        a[i] = lower_bound(q.begin(), q.end(), a[i]) - q.begin();
        while (used[a[i]]) {
            a[i]++;
        }
        used[a[i]] = 1;
    }
    //for (auto elem : a) cout << elem << ' ';
    int cnt = 1;
    int last = -1e9;
    for (int i = 0; i < n; ++i) {
        if (i == 0) {
            last = a[i];
        }
        else if (a[i] - a[i-1]!=1) {
            cnt++;
        }
    }
    cout << cnt;
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:22:9: warning: variable 'last' set but not used [-Wunused-but-set-variable]
   22 |     int last = -1e9;
      |         ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -