답안 #337148

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
337148 2020-12-18T15:50:47 Z deadeye 지구 온난화 (NOI13_gw) C++11
30 / 40
245 ms 33492 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define si second
#define ar array
typedef pair<int,int> pi;
 
#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 69
#endif
template <typename Arg>
void __f(string name, Arg arg) {
	cerr << name << " = " << arg << endl;
}
template <typename Head, typename... Tail>
void __f(string names, Head head, Tail... tail) {
	string cur = "";
	for (auto ch: names){if(ch==','){break;}else{cur+=ch;}}
	string nxt = names.substr(cur.size()+2);
	cerr << cur << " = " << head << ", ";
	__f(nxt, tail...);
}
 
int N, ret, cur;


int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	vector<int> v;
	for (int i = 1; i <= N; ++i) {
		int x; cin >> x;
		if (i == 1) v.pb(x);
		else if (x != v.back()) v.pb(x);
	} 
	int n = v.size();
	if (n == 1) {
		cout << 1;
		return 0;
	}
	vector<ar<int, 2> > events;
	for (int i = 1; i < n - 1; ++i) {
		if (v[i] > v[i - 1] && v[i] > v[i + 1]) {
			events.pb({v[i], 0});
		} else if (v[i] < v[i - 1] && v[i] < v[i + 1]) {
			events.pb({v[i], 1});
		}
	}
	if (v[0] > v[1]) events.pb({v[0], 0});
	if (v[n - 1] > v[n - 2]) events.pb({v[n - 1], 0});
	sort(events.rbegin(), events.rend());
	for (auto i: events) {
		if (!i[1]) cur += 1;
		else cur -= 1;
		ret = max(cur, ret);
	}
	cout << ret;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 2664 KB Output is correct
2 Correct 15 ms 2664 KB Output is correct
3 Correct 15 ms 2664 KB Output is correct
4 Correct 16 ms 2664 KB Output is correct
5 Correct 17 ms 2664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 3308 KB Output is correct
2 Correct 20 ms 3308 KB Output is correct
3 Correct 22 ms 3328 KB Output is correct
4 Correct 22 ms 3308 KB Output is correct
5 Correct 21 ms 3308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 235 ms 24788 KB Output is correct
2 Correct 234 ms 24788 KB Output is correct
3 Correct 230 ms 24788 KB Output is correct
4 Correct 245 ms 24788 KB Output is correct
5 Runtime error 225 ms 33492 KB Memory limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 224 ms 24872 KB Output is correct
2 Correct 225 ms 24720 KB Output is correct
3 Correct 229 ms 24788 KB Output is correct
4 Correct 161 ms 24660 KB Output is correct
5 Correct 162 ms 24660 KB Output is correct