201612-1(中间数),201612-2(工资计算)

//201612-1
#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    scanf("%d", &n);

    int arr[n];
    for (int i = 0; i < n; i++)
        scanf("%d", &arr[i]);

    sort(arr, arr + n);
    int mid = (n - 1) / 2;
    int countMore = 0, countLess = 0;
    for (int i = 0; i < n; i++)
        if (arr[mid] < arr[i])
            countMore++;
        else if (arr[mid] > arr[i])
            countLess++;

    printf("%d\n", countMore == countLess ? arr[mid] : -1);

    return 0;
}

//201612-1
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    int arr[n];
    for (int i = 0; i < n; i++)
        scanf("%d", &arr[i]);

    int countMore, countLess;
    for (int i = 0; i < n; i++) {
        countMore = 0, countLess = 0;
        for (int j = 0; j < n; j++) {
            if (arr[i] > arr[j])
                countMore++;
            if (arr[i] < arr[j])
                countLess++;

        }
        if (countMore == countLess) {
            printf("%d\n", arr[i]);
            break;
        }
        if (i == n - 1) {
            printf("-1\n");
        }
    }
    return 0;
}

//201612-1
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> A(n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &A[i]);
    sort(A.begin(), A.end());
    auto i = equal_range(A.begin(), A.end(), A[A.size() / 2]);
    if (i.first - A.begin() == A.end() - i.second)
        printf("%d", A[A.size() / 2]);
    else
        printf("-1");
    return 0;
}

//201612-1
#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    scanf("%d", &n);

    map<int, int> m;
    for (int i = 0; i < n; i++) {
        int num;
        scanf("%d", &num);
        m[num]++;
    }

    int less = 0;
    int res = -1;
    for (auto it:m) {
        if (n - it.second - less == less)
            res = it.first;
        less += it.second;
    }
    printf("%d\n", res);
    return 0;
}

//201612-2
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    int t;
    scanf("%d", &t);
    for (int i = 100000; i >= 3500; i -= 100) {
        int temp = i - 3500;

        if (temp > 80000) {
            temp = (((temp - 80000) * 45) / 100 + (25000 * 35) / 100 + (20000 * 30) / 100 +
                    (26000 * 25) / 100 +
                    (4500 * 20) / 100 + (3000 * 10) / 100 + (1500 * 3) / 100);
        } else if (temp > 55000) {
            temp = (((temp - 55000) * 35) / 100 + (20000 * 30) / 100 + (26000 * 25) / 100 + (4500 * 20) / 100 +
                    (3000 * 10) / 100 +
                    (1500 * 3) / 100);
        } else if (temp > 35000) {
            temp = (((temp - 35000) * 30) / 100 + (26000 * 25) / 100 + (4500 * 20) / 100 + (3000 * 10) / 100 +
                    (1500 * 3) / 100);

        } else if (temp > 9000) {
            temp = (((temp - 9000) * 25) / 100 + (4500 * 20) / 100 + (3000 * 10) / 100 + (1500 * 3) / 100);

        } else if (temp > 4500) {
            temp = (((temp - 4500) * 20) / 100 + (3000 * 10) / 100 + (1500 * 3) / 100);

        } else if (temp > 1500) {
            temp = (((temp - 1500) * 10) / 100 + (1500 * 3) / 100);

        } else {
            temp = (temp * 3) / 100;

        }

        if (i - temp == t) {
            printf("%d\n", i);
            break;
        }
    }
    if (t < 3500)
        printf("%d", t);

    return 0;
}

//201612-2
#include <bits/stdc++.h>

using namespace std;

int main() {
    int t;
    scanf("%d", &t);
    int sal = 200000;
    vector<pair<int, int>> table{{0,     1500},
                                 {1500,  4500},
                                 {4500,  9000},
                                 {9000,  35000},
                                 {35000, 55000},
                                 {55000, 80000},
                                 {80000, 200000}
    };
    vector<int> interest{3, 10, 20, 25, 30, 35, 45};

    while (sal >= 100) {
        int a = sal - 3500;
        int del = 0;
        for (int i = 0; i < table.size(); i++)
            if (a >= table[i].second)
                del += (table[i].second - table[i].first) * interest[i] / 100;
            else if (a >= table[i].first) {
                del += (a - table[i].first) * interest[i] / 100;
                break;
            }

        if (sal - del == t) {
            printf("%d\n", sal);
            break;
        }
        sal -= 100;
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值