题解 | 左侧严格小于计数

左侧严格小于计数

https://www.nowcoder.com/practice/c5922c6cdd1445749bd42f586c422435

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

int main() {
    int n;
    cin>>n;
    vector<int> arr;
    vector<int> ret;
    for(int i = 0;i<n;i++)
    {
        int tmp;
        cin>>tmp;
        arr.push_back(tmp);
    }
    for(int i = 1;i<n+1;i++)
    {
        if(i == 1)
        {
            ret.push_back(0);
        }
        else {
        int tmp = 0;
        for(int j = 1;j<i;j++)
        {
            if(arr[j-1]<arr[i-1])
                tmp++;
        }
        ret.push_back(tmp);
        }
    }
    for (auto x: ret) {
        cout<<x<<" ";
    }

}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

点赞 评论 收藏
分享
09-02 14:53
... 前端工程师
双尔:露头就秒,骗你的,不露也秒
点赞 评论 收藏
分享
08-06 08:33
四川大学 Java
OPPO官方内推:卧槽!!!啥破公司啊!!!
投递OPPO等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务