답안 #734406

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
734406 2023-05-02T11:23:59 Z Amaarsaa 지구 온난화 (NOI13_gw) C++14
29 / 40
460 ms 20028 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;
		if ( v[i].first != v[i - 1].first) {
			r = max (r, ans);	
		}
		Used[x] = 1;
		
		ans ++;
			if ( Used[x + 1] == 1) ans --;
			if ( Used[x - 1] == 1) 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 340 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 25 ms 2504 KB Output is correct
2 Correct 26 ms 2504 KB Output is correct
3 Correct 26 ms 2428 KB Output is correct
4 Correct 28 ms 2504 KB Output is correct
5 Correct 25 ms 2464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 2460 KB Output is correct
2 Correct 37 ms 2376 KB Output is correct
3 Correct 41 ms 2504 KB Output is correct
4 Correct 43 ms 2496 KB Output is correct
5 Correct 42 ms 2468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 454 ms 19952 KB Output is correct
2 Correct 446 ms 19964 KB Output is correct
3 Correct 437 ms 19972 KB Output is correct
4 Correct 444 ms 20028 KB Output is correct
5 Correct 446 ms 19976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 452 ms 19960 KB Output is correct
2 Correct 441 ms 20020 KB Output is correct
3 Correct 460 ms 19928 KB Output is correct
4 Incorrect 273 ms 19900 KB Output isn't correct
5 Halted 0 ms 0 KB -