# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
313773 |
2020-10-17T04:24:45 Z |
Trickster |
Money (IZhO17_money) |
C++14 |
|
1 ms |
512 KB |
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>
using namespace std;
#define N 1000010
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mod 1000000007
#define pii pair <int, int>
#define sz(a) int(a.size())
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
ll bigmod(ll a,ll e) {if(e==0)return 1;ll x=bigmod(a*a%mod,e>>1);return e&1?x*a%mod:x;}
int n;
int v[N];
int T[N*4];
void upd(int pos, int l, int r, int node)
{
if(l == r) {
T[node]++;
return;
}
if(pos <= (l+r)/2) upd(pos, l, (l+r)/2, node*2);
else upd(pos, (l+r)/2+1, r, node*2+1);
T[node] = T[node*2] + T[node*2+1];
}
int tap(int a, int b, int l, int r, int node)
{
if(l > b || r < a) return 0;
if(l >= a && r <= b) return T[node];
return tap(a, b, l, (l+r)/2, node*2) + tap(a, b, (l+r)/2+1, r, node*2+1);
}
int main()
{
cin >> n;
for(int i = 1; i <= n; i++) cin >> v[i];
int ans = 0, l = 1;
for(int i = 1; i <= n; i++) {
int ok = tap(v[l], v[i+1], 1, n, 1);
if(ok || v[i+1] < v[i]) {
ans ++;
while(l <= i) upd(v[l++], 1, n, 1);
}
}
cout << ans;
}
/*
6
3 6 4 5 1 2
6
5 4 6 3 1 2
*/
Compilation message
money.cpp:22: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
22 | #pragma GCC optimization ("O3")
|
money.cpp:23: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
23 | #pragma GCC optimization ("unroll-loops")
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
4 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |