Submission #375979

# Submission time Handle Problem Language Result Execution time Memory
375979 2021-03-10T11:59:55 Z anonymity Money (IZhO17_money) C++17
0 / 100
1 ms 364 KB
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <cassert>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
/*#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
//oset<int> a;
//a.insert(p);
//a.erase(p);
//int k = *a.find_by_order(id);
*/
using namespace std;
#define int long long
#define ii pair<int, int> 
#define fi first
#define se second
#define endl '\n'
#define mp make_pair
#define pb push_back
#define inf 1e18
int power(int x, int y, int m) {
    int res = 1;
	while (y > 0)
    {
        if (y & 1) res = res * x % m;
        y = y >> 1;
        x = x * x % m;
    }
    return res;
}
int n, a[1000005], m = 1, pos, s = 1, k;
vector <ii> so;
vector <int> b;
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) 
	{
		cin >> a[i];
		so.pb(mp(a[i], i));
	}
	sort(so.begin(), so.end());
	for (int i = 0; i < n; i++)
		a[so[i].se] = i + 1;
	for (int i = 1; i <= n; i++)
		cout << a[i] << ' ';
	for (int i = 1; i <= n; i++)
	{
		if (a[i] > a[i - 1]) k++;
		else k = 1;
		if (k > m) pos = i;
		m = max(m, k);
	}
	for (int i = 1; i <= n; i++)
		if (i < pos - m + 1 || i > pos) b.pb(a[i]);
	if (!b.empty()) s++;
	for (int i = 1; i < b.size(); i++)
		if (b[i] != b[i - 1] + 1) s++;
	cout << s;
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:82:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |  for (int i = 1; i < b.size(); i++)
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -