Submission #173046

# Submission time Handle Problem Language Result Execution time Memory
173046 2020-01-03T08:17:35 Z tourist Money (IZhO17_money) C++14
0 / 100
2 ms 256 KB
#include <iostream>
#include <vector>

using namespace std;

#define ll long long
#define sz(x) (int)x.size()
#define pii pair < int, int >
#define endl "\n"
#define METH ios::sync_with_stdio(0); cin.tie(0);
#define BEGIN cout << "BEGIN" << endl;
#define END cout << "END" << endl;

const int mod = 1e9 + 7;															/// ANOTHER HASH MOD: 228228227
const int prime = 29;																	/// ANOTHER HASH PRIME: 997
const int INF = ((long long) 0xCAFEBABE - 1e9 - 4e8);

int n;
vector < int > v, nw;

inline void read() {
	v.push_back(0);
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int a; scanf("%d", &a);
		v.push_back(a);
	}
}

bool sorted(int l, int r) {
	for (int i = l; i < r; i++) {
		if (v[i] > v[i + 1]) {
			return false;
		}
	}

	return true;
}

int check(int l, int r) {
	if (sorted(l, r)) {
		if (nw.size() == 0) {
			return 0;
		}

		if (nw.size() == 1) {
			if (v[l] >= nw[0]) {
				return 0;
			} else {
				return -1;
			}
		}

		for (int i = 1; i < nw.size(); i++) {
			if (nw[i - 1] <= v[l] && v[r] <= nw[i]) {
				return (i - 1);
			}
		}

		if (v[r] <= nw[0]) {
			return -1;
		}

		if (nw.back() <= v[l]) {
			return nw.size();
		}
	}

	return -2;
}

void put(int l, int r, int place) {
	vector < int > temp;
	for (int i = 0; i <= place && i < nw.size(); i++) {
		temp.push_back(nw[i]);
	}

	for (int i = l; i <= r; i++) {
		temp.push_back(v[i]);
	}

	for (int i = place + 1; i < nw.size(); i++) {
		temp.push_back(nw[i]);
	}

	nw = temp;
}

inline void solve() {
	int l = 1, ans = 0;
	for (int r = 1; r <= n; r++) {
		if (v[r] > v[r + 1]) {
			ans++;
		}
	}

	cout << ans << endl;
}

int main() {
	int t = 1;
	//scanf("%d", &t);

	//precalc();
	while (t--) {
		//purify();
		read();
		solve();
	}
}

Compilation message

money.cpp: In function 'int check(int, int)':
money.cpp:54:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 1; i < nw.size(); i++) {
                   ~~^~~~~~~~~~~
money.cpp: In function 'void put(int, int, int)':
money.cpp:74:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i <= place && i < nw.size(); i++) {
                                ~~^~~~~~~~~~~
money.cpp:82:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = place + 1; i < nw.size(); i++) {
                          ~~^~~~~~~~~~~
money.cpp: In function 'void solve()':
money.cpp:90:6: warning: unused variable 'l' [-Wunused-variable]
  int l = 1, ans = 0;
      ^
money.cpp: In function 'void read()':
money.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
money.cpp:25:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a; scanf("%d", &a);
          ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -