답안 #329139

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
329139 2020-11-19T12:52:09 Z oak Mountains (NOI20_mountains) C++14
0 / 100
2000 ms 3108 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,j,i;
	scanf("%d",&n);
	int arr[n],sum[n];
	multiset<int> ms;
	for(i=0;i<n;i++){
		scanf("%d",&arr[i]);
		ms.insert(arr[i]);
		sum[i] = distance(ms.begin(),ms.lower_bound(arr[i]));
		//printf("%d ",sum[i]);
	}
	//printf("\n");
	long long ans = 0;
	ms.clear();
	for(i=n-1;i>=0;i--){
		ms.insert(arr[i]);
		sum[i] *= distance(ms.begin(),ms.lower_bound(arr[i]));
		ans += sum[i];
		//printf("%d ",sum[i]);
	}
	//printf("\n");
	printf("%lld",ans);
}

Compilation message

Mountains.cpp: In function 'int main()':
Mountains.cpp:4:8: warning: unused variable 'j' [-Wunused-variable]
    4 |  int n,j,i;
      |        ^
Mountains.cpp:5:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    5 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
Mountains.cpp:9:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |   scanf("%d",&arr[i]);
      |   ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Execution timed out 2074 ms 2540 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2092 ms 3108 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2092 ms 3108 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2092 ms 3108 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 2074 ms 2540 KB Time limit exceeded
3 Halted 0 ms 0 KB -