답안 #329142

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
329142 2020-11-19T13:02:32 Z M_W Mountains (NOI20_mountains) C++14
64 / 100
2000 ms 10064 KB
#include <bits/stdc++.h>
using namespace std;
long long h[300300];
vector<long long> v;

int main(){
	int N;
	vector<long long> cnt;
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%lld", &h[i]);
		if(i == 0){
			v.push_back(h[i]);
			cnt.push_back(0);
			continue;
		}
		auto it = upper_bound(v.begin(), v.end(), h[i]);
		v.insert(it, h[i]);
		cnt.push_back(lower_bound(v.begin(), v.end(), h[i]) - v.begin());
	}
	v.clear();
	long long sum = 0;
	for(int i = N - 1; i >= 0; i--){
		if(i == 0){
			v.push_back(h[i]);
			cnt.push_back(0);
			continue;
		}
		auto it = upper_bound(v.begin(), v.end(), h[i]);
		v.insert(it, h[i]);
		sum += cnt[i] * 1ll * (lower_bound(v.begin(), v.end(), h[i]) - v.begin()) * 1ll;
	}
	printf("%lld", sum);
}

Compilation message

Mountains.cpp: In function 'int main()':
Mountains.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
Mountains.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |   scanf("%lld", &h[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Execution timed out 2095 ms 10064 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2072 ms 4944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2072 ms 4944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 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 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 23 ms 804 KB Output is correct
12 Correct 23 ms 876 KB Output is correct
13 Correct 23 ms 804 KB Output is correct
14 Correct 22 ms 748 KB Output is correct
15 Correct 22 ms 748 KB Output is correct
16 Correct 23 ms 748 KB Output is correct
17 Correct 22 ms 748 KB Output is correct
18 Correct 23 ms 748 KB Output is correct
19 Correct 21 ms 748 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2072 ms 4944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Execution timed out 2095 ms 10064 KB Time limit exceeded
3 Halted 0 ms 0 KB -