답안 #522927

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
522927 2022-02-06T13:23:21 Z Sanzhar23 Money (IZhO17_money) C++14
45 / 100
1 ms 448 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long	
#define pb push_back
#define bug cout << "bug" << endl
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define pll pair <ll, ll> 
#define pii pair <int, int> 
#define triple pair <pair <ll, ll> , ll>  
#define ull unsigned long long
#define ld long double
#define pinode pair <node*, node*>

const ll INF = 9e18 + 5;
const ll inf = 1e9 + 5;
const ll N = 3e2 + 5;
const ll shift = 2e6;
const ll mod = 1e9 + 7;
const ll M = 10000 + 5;
const ll LOG = 21;
const ll sp = 263;
const ll block = 500;
const double eps = 1e-10;
	
int n, a[N], ans = 0;
vector <int> cur;

int main(){
    speed;
    cin >> n;
    for(int i = 1; i <= n; i++)
    	cin >> a[i];
    int st = 1;
    cur.pb(0);
    cur.pb(1e6 + 1);
    while(st <= n){
    	int nw;
    	ans++;
 		for(int i = st; i <= n; i++){
 			int ok = 0;
			for(int j = 1; j < cur.size(); j++){
				if(i != st){
					if(a[i] < a[i - 1])
						break;
				}
				if(a[st] >= cur[j - 1] && a[i] <= cur[j])
					ok = 1;
			}	
			if(ok){
				nw = i + 1;
				continue;
			}
			break;
		}   	
		vector <int> f;
		f.pb(0);
		for(int j = 1; j < cur.size(); j++){
			if(a[st] >= cur[j - 1] && a[nw - 1] <= cur[j]){
				for(int i = st; i <= nw - 1; i++){
					f.pb(a[i]);
				}
				for(int i = j; i < cur.size(); i++){
					f.pb(cur[i]);
				}
				break;		
			}
			f.pb(cur[j]);
		}
		cur = f;
		st = nw;
	}
	cout << ans << endl;
}
/*	
%I64d



		
		



%I64d
*/ 

Compilation message

money.cpp: In function 'int main()':
money.cpp:46:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |    for(int j = 1; j < cur.size(); j++){
      |                   ~~^~~~~~~~~~~~
money.cpp:62:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |   for(int j = 1; j < cur.size(); j++){
      |                  ~~^~~~~~~~~~~~
money.cpp:67:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     for(int i = j; i < cur.size(); i++){
      |                    ~~^~~~~~~~~~~~
money.cpp:42:10: warning: 'nw' may be used uninitialized in this function [-Wmaybe-uninitialized]
   42 |      int nw;
      |          ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 0 ms 312 KB Output is correct
13 Correct 0 ms 316 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 0 ms 312 KB Output is correct
13 Correct 0 ms 316 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 312 KB Output is correct
18 Correct 0 ms 316 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 0 ms 316 KB Output is correct
23 Correct 0 ms 316 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 324 KB Output is correct
26 Correct 0 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 0 ms 312 KB Output is correct
13 Correct 0 ms 316 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 312 KB Output is correct
18 Correct 0 ms 316 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 0 ms 316 KB Output is correct
23 Correct 0 ms 316 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 324 KB Output is correct
26 Correct 0 ms 316 KB Output is correct
27 Correct 1 ms 320 KB Output is correct
28 Correct 1 ms 316 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 312 KB Output is correct
31 Correct 1 ms 292 KB Output is correct
32 Correct 1 ms 308 KB Output is correct
33 Correct 1 ms 324 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 308 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 0 ms 312 KB Output is correct
13 Correct 0 ms 316 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 312 KB Output is correct
18 Correct 0 ms 316 KB Output is correct
19 Correct 1 ms 316 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 0 ms 316 KB Output is correct
23 Correct 0 ms 316 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 324 KB Output is correct
26 Correct 0 ms 316 KB Output is correct
27 Correct 1 ms 320 KB Output is correct
28 Correct 1 ms 316 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 312 KB Output is correct
31 Correct 1 ms 292 KB Output is correct
32 Correct 1 ms 308 KB Output is correct
33 Correct 1 ms 324 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 308 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 320 KB Output is correct
39 Runtime error 1 ms 448 KB Execution killed with signal 11
40 Halted 0 ms 0 KB -