# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
75085 |
2018-09-08T09:38:52 Z |
Nordway |
Money (IZhO17_money) |
C++14 |
|
2 ms |
820 KB |
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define boost ios_base::sync_with_stdio(0),cin.tie(0),cout.tie()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = INT_MAX;
const ll mod = 1e9 + 7;
const int pi = acos(-1);
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int N = 1e6;
const int MAXN = 1e6 + 1;
int t[4 * MAXN], a[MAXN];
void upd(int v, int tl, int tr, int pos){
if(tl == tr){
t[v]++;
return ;
}
int tm = (tl + tr) / 2;
if(pos <= tm)upd(v * 2, tl, tm, pos);
else upd(v * 2 + 1, tm + 1, tr, pos);
t[v] = t[v * 2] + t[v * 2 + 1];
}
int get(int v, int tl, int tr, int l, int r){
if(l > r || tl > r || l > tr)return 0;
if(l <= tl && tr <= r)return t[v];
int tm = (tl + tr) / 2;
return get(v * 2, tl, tm, l, r) + get(v * 2 + 1, tm + 1, tr, l, r);
}
int main(){
boost;
int n;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
int ans = 0;
for(int i = 1; i <= n; ){
int l = i, r = i + 1;
ans++;
while(r <= n){
if(get(1, 1, N, a[l], a[r] - 1) > 0 || a[r] < a[r - 1])break;
r++;
}
for(int j = l; j < r; j++)upd(1, 1, N, a[j]);
i = r;
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
644 KB |
Output is correct |
3 |
Correct |
2 ms |
756 KB |
Output is correct |
4 |
Incorrect |
2 ms |
820 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
644 KB |
Output is correct |
3 |
Correct |
2 ms |
756 KB |
Output is correct |
4 |
Incorrect |
2 ms |
820 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
644 KB |
Output is correct |
3 |
Correct |
2 ms |
756 KB |
Output is correct |
4 |
Incorrect |
2 ms |
820 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
644 KB |
Output is correct |
3 |
Correct |
2 ms |
756 KB |
Output is correct |
4 |
Incorrect |
2 ms |
820 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |