14023: 【原4023】面包比可爱

题目描述

author: SupremeT 原OJ链接：https://acm.sjtu.edu.cn/OnlineJudge-old/problem/4023

Sample Input

``````6
4 3 0 5 1 2
``````

Sample Output

``````0 0 0 3 1 2
``````

FineArtz's solution

``````/* 面包比可爱 */
#include <iostream>
using namespace std;

int main(){
int n = 0, a[100], ans[100] = {0};
cin >> n;
for (int i = 0; i < n; ++i) cin >> a[i];
for (int i = 0; i < n; ++i)
for (int j = 0; j <= i - 1; ++j)
if (a[i] > a[j]) ++ans[i];
for (int i = 0; i < n; ++i) cout << ans[i] << ' ';
cout << endl;
return 0;
}
``````

ligongzzz's solution

``````#include <iostream>
#include <vector>
using namespace std;

int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

int n;
cin >> n;

vector<int> val(n);

for (int i = 0; i < n; ++i) {
cin >> val[i];
int cnt = 0;
for (int j = 0; j < i; ++j)
if (val[j] < val[i])
++cnt;
cout << cnt << " ";
}

return 0;
}
``````

yyong119's solution

``````#include <iostream>
using namespace std;

const int MAX_N = 100;
int a[MAX_N + 5];

int main() {
int n; cin >> n;
for (int i = 0; i < n; ++i) {
cin >> a[i];
int tmp = 0;
for (int j = 0; j < i; ++j)
if (a[j] < a[i]) ++tmp;
cout << tmp << " ";
}
return 0;
}
``````