LeetCode Biweekly Contest 3
問題文
省略
省略
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S chmax(S &a, T b){
if(a<b){
a=b;
}
return a;
}
class Solution{
public:
int twoSumLessThanK(vector<int>& A, int K){
int N=A.size(), S, i, j, res=-1;
for(i=0;i<N;i++){
for(j=i+1;j<N;j++){
S = A[i] + A[j];
if(S < K){
chmax(res, S);
}
}
}
return res;
}
}
;
// cLay varsion 20190630-1
// --- original code ---
// class Solution {
// public:
// int twoSumLessThanK(vector<int>& A, int K) {
// int i, j, res = -1;
// int S;
// int N = A.size();
// rep(i,N) rep(j,i+1,N){
// S = A[i] + A[j];
// if(S < K) res >?= S;
// }
// return res;
// }
// };
// {
// // main関数を適当に処理する
// }
Current time: 2024年05月03日10時54分57秒
Last modified: 2019年06月30日03時00分04秒 (by laycrs)
Tags: Competitive_Programming_Incomplete LeetCode
トップページに戻る
Logged in as: unknown user (not login)