답안 #734386

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
734386 2023-05-02T11:08:17 Z Amaarsaa 지구 온난화 (NOI13_gw) C++14
6 / 40
1000 ms 48948 KB
#include<bits/stdc++.h>
 
using namespace std;
using ll = int;
ll n, ans, p, j, s, x;
int main() {
	ll i, t, r;
	cin >> n;
	map < int, int > Used, Howmuch;
	vector < pair < ll, ll > > v;
	for ( i = 1; i <= n; i ++) {
		cin >> x;
		Howmuch[x] ++;
		v.push_back(make_pair(x, i));
		
	}	
	ans = 0;
	sort ( v.begin(), v.end());
	r = 0;
	for ( i = n - 1; i >= 0; i --) {
		x = v[i].second;
		if ( Howmuch[v[i].first] == 1) {
			ans ++;
			if ( Used[x + 1] == 1) ans --;
			if ( Used[x - 1] == 1) ans --;
			Used[x] ++;	
		}
		Howmuch[v[i].first] --;
		
		r = max (r, ans);
	}
	cout << r << endl;
}

Compilation message

gw.cpp: In function 'int main()':
gw.cpp:7:8: warning: unused variable 't' [-Wunused-variable]
    7 |  ll i, t, r;
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 32 ms 1468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 149 ms 10468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1072 ms 48948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 34920 KB Time limit exceeded
2 Halted 0 ms 0 KB -