Submission #832726

# Submission time Handle Problem Language Result Execution time Memory
832726 2023-08-21T14:15:24 Z DarkMatter Baloni (COCI15_baloni) C++14
0 / 100
411 ms 420 KB
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int>pi;
typedef pair<ll, ll>pl;
typedef vector<pi>vpi;
typedef vector<pl>vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
const long double PI = acos(-1);
const ll oo = 1e18;
const int MOD = 1e9 + 7;
const int N = 2e5 + 7;
#define endl '\n'
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define read(v) for (auto& it : v) scanf("%d", &it);
#define readL(v) for (auto& it : v) scanf("%lld", &it);
#define print(v) for (auto it : v) printf("%d ", it); puts("");
#define printL(v) for (auto it : v) printf("%lld ", it); puts("");
void solve() {
	int n;
	cin >> n;
	vi v(n);
	for (auto& it : v)
		cin >> it;
	int ans = 0;
	while (v.size() > 0) {
		int h = v[0] - 1;
		for (int j = 1; j < v.size(); j++)
			if (v[j] == h)
				h--, v.erase(v.begin() + (j--));
		v.erase(v.begin());
		ans++;
	}
	cout << ans << endl;
}
int t = 1;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#endif
	//scanf("%d", &t);
	while (t--) solve();
}

Compilation message

baloni.cpp: In function 'void solve()':
baloni.cpp:37:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   for (int j = 1; j < v.size(); j++)
      |                   ~~^~~~~~~~~~
baloni.cpp: In function 'int main()':
baloni.cpp:48:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |  freopen("input.txt", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 366 ms 412 KB Output isn't correct
2 Incorrect 378 ms 416 KB Output isn't correct
3 Incorrect 358 ms 412 KB Output isn't correct
4 Incorrect 411 ms 408 KB Output isn't correct
5 Incorrect 395 ms 416 KB Output isn't correct
6 Incorrect 387 ms 416 KB Output isn't correct
7 Incorrect 364 ms 340 KB Output isn't correct
8 Incorrect 365 ms 420 KB Output isn't correct
9 Incorrect 368 ms 412 KB Output isn't correct
10 Incorrect 360 ms 416 KB Output isn't correct