Uva1149-Erasing ans Winning
程序员文章站
2022-03-11 19:21:59
...
#include<iostream>
#include <math.h>
#include<algorithm>
#include<vector>
using namespace std;
vector<int> arr;
int pro(int ctn);
int main() {
int T;
cin >> T;
while (T--) {
arr.clear();
int n,ctn;
cin >> n;
cin >> ctn;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
arr.push_back(x);
}
cout<<pro(ctn);
}
}
int pro(int ctn) {
int num = 0;
sort(arr.begin(),arr.end());
int r = arr.size() - 1;
int l = 0;
for (r; r >= l; r--) {
if (arr[r] + arr[l] <= ctn && r != l) {
num++;
l++;
}
else {
num++;
}
}
return num;
}
推荐阅读
-
ANS.1的基础总结
-
Winning Cells
-
如何去除Matlab里面的ans?
-
|sex[]_sum[],G_ans|L2-028 秀恩爱分得快
-
APIO2014 Beads ans wires[树形DP]
-
《Design of Computer Programs》学习笔记(1 - 1)Winning Poker Hands - Lesson 1
-
《Design of Computer Programs》学习笔记(1 - 2)Winning Poker Hands - Bonus:Shuffling
-
POJ1568_Find the Winning Move(α-β剪枝)
-
UVa11491 Erasing and Winning 奖品的价值
-
Uva1149-Erasing ans Winning