답안 #38094

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
38094 2018-01-01T05:37:40 Z nibnalin Money (IZhO17_money) C++14
0 / 100
0 ms 5920 KB
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

const int maxn = int(1e6)+5;

int A[maxn];

int main(void)
{
	int n;
	scanf("%d", &n);
	vector<pair<int, int>> B;
	for(int i = 0;i < n;i++)
	{
		scanf("%d", &A[i]);
		B.push_back({A[i], i});
	}

	sort(B.begin(), B.end());

	int res = bool(B[0].second);
	for(int i = 1;i < n;i++)
	{
		if(B[i].second < B[i-1].second) res++;
	}
	printf("%d\n", res);
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:14:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
money.cpp:18:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &A[i]);
                     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5920 KB Output is correct
2 Incorrect 0 ms 5920 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5920 KB Output is correct
2 Incorrect 0 ms 5920 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5920 KB Output is correct
2 Incorrect 0 ms 5920 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 5920 KB Output is correct
2 Incorrect 0 ms 5920 KB Output isn't correct
3 Halted 0 ms 0 KB -