# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1112430 |
2024-11-14T07:44:19 Z |
vjudge1 |
Baloni (COCI15_baloni) |
C++17 |
|
2000 ms |
7248 KB |
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define nmod(a, b) (((a%b)+b)%b) // stands for [n]atural [mod], as in "will always return a natural number", should be used in case of negative
#define a2b(a, b) (a << b) // a*2^b
#define bit(a, b) ((a >> b) & 1) // bth bit from the right, starts at zero
using namespace std;
template<class T> using vec = vector<T>;
const int INFTY = (1LL << 63) - 1;
const int NNFTY = 1LL << 63;
int32_t main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n; cin >> n;
vec<int> h(n); for (auto &x : h) cin >> x;
vec<bool> ok(n, false);
int k = 0;
for (int i = 0; i < n; i++) {
if (!ok[i]) {
k++;
int li = i;
ok[i] = true;
for (int j = li + 1; j < n; j++) {
if (ok[j]) continue;
if (h[li] - h[j] == 1) ok[j] = true, li = j;
}
}
}
cout << k;
}
Compilation message
baloni.cpp:10:31: warning: integer overflow in expression of type 'long long int' results in '9223372036854775807' [-Woverflow]
10 | const int INFTY = (1LL << 63) - 1;
| ~~~~~~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
4 ms |
336 KB |
Output is correct |
3 |
Correct |
6 ms |
336 KB |
Output is correct |
4 |
Correct |
10 ms |
336 KB |
Output is correct |
5 |
Execution timed out |
2059 ms |
6728 KB |
Time limit exceeded |
6 |
Execution timed out |
2069 ms |
7248 KB |
Time limit exceeded |
7 |
Execution timed out |
2071 ms |
6240 KB |
Time limit exceeded |
8 |
Execution timed out |
2037 ms |
6108 KB |
Time limit exceeded |
9 |
Execution timed out |
2068 ms |
6424 KB |
Time limit exceeded |
10 |
Execution timed out |
2069 ms |
6728 KB |
Time limit exceeded |