-
카테고리
-
세부 분야
알고리즘 · 자료구조
-
해결 여부
미해결
26번 질문입니다.
20.08.07 15:57 작성 조회수 181
0
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
int n, cnt;
scanf("%d", &n);
vector<int> a(n);
for (int i = 0; i < n; i++)
scanf("%d", &a[i]);
for (int i = 0; i < n; i++) {
cnt = i + 1;
for (int j = 0; j < i; j++) {
if (a[i] > a[j])
cnt--;
}
printf("%d ", cnt);
}
}
선생님 저는 이렇게 풀었는데 O(n2) 알고리즘인데 4,5번에서 time_limit이 납니다.
컴퓨터 때문인가해서 질문드립니다.
답변을 작성해보세요.
0
답변 1