链接:https://www.nowcoder.com/acm/contest/185/C
来源:牛客网
一共一行,第 i 个数和第 i+1 个数中间用空格隔开.
$O(n^2),10000 \times 10000$枚举,看起来虽然有点险奈何常数小啊。
#include <algorithm> #include <iostream> #include <cstring> #include <cstdio> #include <cmath> using namespace std; #define LL long long LL a[10006],n; int main() { scanf("%lld",&n); for(int i=1;i<=n;i++)scanf("%lld",&a[i]); for(int i=1;i<=n;i++) { for(int j=i+1;j<=n;j++) { if(a[j]>a[i]) { printf("%d ",j); break; } if(j==n)printf("0 "); } } printf("0"); return 0; }
原文:https://www.cnblogs.com/rmy020718/p/9602470.html