답안 #163766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
163766 2019-11-15T08:55:45 Z MvC Money (IZhO17_money) C++11
100 / 100
244 ms 15128 KB
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e6+50;
const int mod=1e9+7;
using namespace std;
int n,i,a[nmax],rs,j,fw[nmax],t;
void upd(int i)
{
	for(;i<=1e6;i+=i&(-i))fw[i]++;
}
int qry(int i)
{
	int rs=0;
	for(;i>=1;i-=i&(-i))rs+=fw[i];
	return rs;
}
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			if((a[i]!=a[j] && qry(a[j]-1)!=qry(a[i])) || a[j]<a[j-1])break;
		}
		for(t=i;t<j;t++)upd(a[t]);
		rs++;
		i=j-1;
	}
	cout<<rs<<endl;
	return 0;
}

Compilation message

money.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
money.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 13 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 424 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 508 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 13 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 424 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 508 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 380 KB Output is correct
18 Correct 2 ms 508 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 13 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 424 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 508 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 380 KB Output is correct
18 Correct 2 ms 508 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 632 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 504 KB Output is correct
33 Correct 9 ms 376 KB Output is correct
34 Correct 2 ms 504 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 3 ms 1528 KB Output is correct
38 Correct 4 ms 1656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 13 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 424 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 508 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 380 KB Output is correct
18 Correct 2 ms 508 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 632 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 504 KB Output is correct
33 Correct 9 ms 376 KB Output is correct
34 Correct 2 ms 504 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 3 ms 1528 KB Output is correct
38 Correct 4 ms 1656 KB Output is correct
39 Correct 86 ms 5572 KB Output is correct
40 Correct 145 ms 9032 KB Output is correct
41 Correct 72 ms 4600 KB Output is correct
42 Correct 67 ms 4348 KB Output is correct
43 Correct 48 ms 3192 KB Output is correct
44 Correct 184 ms 11104 KB Output is correct
45 Correct 184 ms 11128 KB Output is correct
46 Correct 180 ms 11400 KB Output is correct
47 Correct 154 ms 11244 KB Output is correct
48 Correct 167 ms 11196 KB Output is correct
49 Correct 193 ms 14968 KB Output is correct
50 Correct 194 ms 15128 KB Output is correct
51 Correct 197 ms 14968 KB Output is correct
52 Correct 192 ms 14988 KB Output is correct
53 Correct 202 ms 14968 KB Output is correct
54 Correct 197 ms 14840 KB Output is correct
55 Correct 211 ms 15044 KB Output is correct
56 Correct 206 ms 14840 KB Output is correct
57 Correct 234 ms 14840 KB Output is correct
58 Correct 244 ms 15100 KB Output is correct
59 Correct 210 ms 14952 KB Output is correct
60 Correct 215 ms 14892 KB Output is correct
61 Correct 206 ms 14968 KB Output is correct
62 Correct 232 ms 14968 KB Output is correct