# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
170510 |
2019-12-25T14:31:26 Z |
dxz05 |
Money (IZhO17_money) |
C++14 |
|
22 ms |
23800 KB |
#include <bits/stdc++.h>
using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define SZ(x) ((int)x.size())
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1e9;
const int MOD = 1000000007;
const int N = 1001000;
const int M = 2511;
int a[N];
VI v[N];
void solve() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
set<int> s;
s.insert(-1);
s.insert(1e7);
int ans = 0;
int l = -1;
int r = 1e7;
for (int i = 1; i <= n; i++) {
if (a[i] > a[i - 1] && a[i] <= r) {
s.insert(a[i]);
} else {
// cout << " | ";
s.insert(a[i]);
r = *++s.find(a[i]);
ans++;
}
//cout << a[i] << ' ';
}
cout << ans << endl;
}
int main() {
ios_base::sync_with_stdio(false);
#ifdef dxz05
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
#endif
int T = 1;
//cin >> T;
while (T--) {
solve();
}
return 0;
}
Compilation message
money.cpp: In function 'void solve()':
money.cpp:51:9: warning: unused variable 'l' [-Wunused-variable]
int l = -1;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
23800 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
23800 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
23800 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
23800 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |