답안 #734410

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
734410 2023-05-02T11:30:39 Z Amaarsaa 지구 온난화 (NOI13_gw) C++14
40 / 40
475 ms 22800 KB
#include<bits/stdc++.h>
 
using namespace std;
using ll = long long;
ll n, ans, p, j, s, x;
	int Used[2000005] = {0};
int main() {
	ll i, t, r;
	cin >> n;

	vector < pair < ll, ll > > v;
	v.push_back(make_pair(-1, -1));
	for ( i = 1; i <= n; i ++) {
		cin >> x;
		v.push_back(make_pair(x, i));
		
	}	
	ans = 0;
	sort ( v.begin(), v.end());
	r = 0;
	for ( i = n; i >= 1; i --) {
		
		x = v[i].second;
		Used[x] = 1;
		
		ans ++;
			if ( Used[x + 1] == 1) ans --;
			if ( Used[x - 1] == 1) ans --;
		if ( v[i].first != v[i - 1].first) {
			r = max (r, ans);	
		}
		
	}
	cout << r << endl;
}

Compilation message

gw.cpp: In function 'int main()':
gw.cpp:8:8: warning: unused variable 't' [-Wunused-variable]
    8 |  ll i, t, r;
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 2416 KB Output is correct
2 Correct 27 ms 2496 KB Output is correct
3 Correct 28 ms 2432 KB Output is correct
4 Correct 28 ms 2504 KB Output is correct
5 Correct 28 ms 2404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 2420 KB Output is correct
2 Correct 34 ms 2372 KB Output is correct
3 Correct 42 ms 2404 KB Output is correct
4 Correct 59 ms 2372 KB Output is correct
5 Correct 40 ms 2456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 457 ms 20080 KB Output is correct
2 Correct 459 ms 19928 KB Output is correct
3 Correct 473 ms 20028 KB Output is correct
4 Correct 449 ms 19880 KB Output is correct
5 Correct 448 ms 19896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 475 ms 19920 KB Output is correct
2 Correct 461 ms 19968 KB Output is correct
3 Correct 459 ms 20032 KB Output is correct
4 Correct 284 ms 19924 KB Output is correct
5 Correct 294 ms 22800 KB Output is correct