OPPO研发通用算法题

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

int main() {    
    int n;
    cin>>n;
    vector<int> appScore;
    vector<int> perScore;
    int a,b;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        appScore.push_back(a);
        perScore.push_back(b);
    }

    int min1 = 1e9 + 1, min2 = 1e9 + 1, max1 = 0, max2 = 0;
    int minn1 = 1e9 + 1, minn2 = 1e9 + 1, maxx1 = 0, maxx2 = 0;

    long long su1 = 0, su2 = 0;
    for (int i = 0; i < n; i ++) {
        su1 += appScore[i]; su2 += perScore[i];
        if (appScore[i] <= min1) {
            min2 = min1; min1 = appScore[i];
        }
        else if (appScore[i] <= min2) {
            min2 = appScore[i];
        }
        if (appScore[i] >= max1) {
            max2 = max1; max1 = appScore[i];
        }
        else if (appScore[i] >= max2){
            max2 = appScore[i];
        }

        if (perScore[i] <= minn1) {
            minn2 = min1; minn1 = perScore[i];
        }
        else if (perScore[i] <= minn2) {
            minn2 = perScore[i];
        }
        if (perScore[i] >= maxx1) {
            maxx2 = maxx1; maxx1 = perScore[i];
        }
        else if (perScore[i] >= maxx2){
            maxx2 = perScore[i];
        }
    }
    
    for (int i = 0; i < n; i ++) {
        double aa, bb;
        long long t1 = su1 - appScore[i], t2 = su2 - perScore[i];
        appScore[i] == min1 ? t1 -= min2 : t1 -= min1;
        appScore[i] == max1 ? t1 -= max2 : t1 -= max1;

        perScore[i] == minn1 ? t1 -= minn2 : t1 -= minn1;
        perScore[i] == maxx1 ? t1 -= maxx2 : t1 -= maxx1;

        aa = 1.0 * t1 / (n - 3); bb = 1.0 * t2 / (n - 3);

        cout << (aa + bb) / 2 <<"\n";
    }
    
    
    return 0;
}
// 64 位输出请用 printf("%lld")
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {    
    int n;
    cin>>n;
    vector<vector<int>> aa(n + 1, vector<int>(2));
    for(int i=1;i<=n;i++){
        cin >> aa[i][0] >>aa[i][1];
    }

    int mi1[2], mi2[2], ma1[2], ma2[2];
    for (int i = 0; i < 2; i ++) {
        mi1[i] = mi2[i] = 1e9 + 1;
        ma1[i] = ma2[i] = 0;
    }

    long long su[2] = {0, 0};
    for (int i = 1; i <= n; i ++) {
        for (int j = 0; j < 2; j ++) {
            su[j] += aa[i][j];
            if (aa[i][j] <= mi1[j]) {
                mi2[j] = mi1[j]; mi1[j] = aa[i][j];
            }
            else if (aa[i][j] <= mi2[j]){
                mi2[j] = aa[i][j];
            }
            if (aa[i][j] >= ma1[j]){
                ma2[j] = ma1[j]; ma1[j] = aa[i][j];
            }
            else if (aa[i][j] >= ma2[j]){
                ma2[j] = aa[i][j];
            }
        }
    }
    
    for (int i = 1; i <= n; i ++) {
        double ans[2];
        long long tt[2];
       
       for (int j = 0; j < 2; j ++) {
            tt[j] = su[j] - aa[i][j];
            tt[j] -= aa[i][j] == mi1[j] ? mi2[j] : mi1[j];
            tt[j] -= aa[i][j] == ma1[j] ? ma2[j] : ma1[j];  
            ans[j] = 1.0 * tt[j] / (n - 3);
       }
        cout << (ans[0] + ans[1]) / 2 <<"\n";
    }
    
    
    return 0;
}
// 64 位输出请用 printf("%lld")
#include <iostream>
using namespace std;

int main() {
    int n;
    string s,t,target;
    cin>>n;
    cin>>s>>t>>target;
    for(int i=0;i<n;i++){
        if(s[i]==target[i] || t[i]==target[i]){
            if(i==n-1){
                cout<< "Yes";
            }
            continue;           
        }
        else{
            cout<< "No";
            return 0;
        }       
    }
    return 0;     
}
// 64 位输出请用 printf("%lld")

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值