mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Add MUTC 2017 Team 5
This commit is contained in:
parent
e3c66c7238
commit
a197ab75bd
|
@ -0,0 +1,38 @@
|
|||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <deque>
|
||||
#include <queue>
|
||||
#include <map>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
using namespace std;
|
||||
int main() {
|
||||
int testcases;
|
||||
cin >> testcases;
|
||||
while (testcases--) {
|
||||
long long n, m;
|
||||
long long ex = 0;
|
||||
cin >> n >> m;
|
||||
if (m < n - 1) {
|
||||
ex = n - m - 1;
|
||||
n = n - ex;
|
||||
}
|
||||
long long emax = n*(n - 1) / 2;
|
||||
long long dec = emax - m;
|
||||
if (dec < 0)
|
||||
dec = 0;
|
||||
long long ans;
|
||||
//cout << "emax=" << emax << endl;
|
||||
//cout << "dec =" << dec << endl;
|
||||
//cout << "ex =" << ex << endl;
|
||||
if (ex > 0)
|
||||
ans = 2 * dec + n*(n - 1) + n*ex*(ex+n)+ex*(ex+n-1)*(ex+n);
|
||||
else
|
||||
ans = 2 * dec + n*(n - 1);
|
||||
cout << ans << endl;
|
||||
}
|
||||
}
|
33
HDOJ/Multi-University Training Contest/2017/Team 5/1011.cpp
Normal file
33
HDOJ/Multi-University Training Contest/2017/Team 5/1011.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include <vector>
|
||||
#include <cstdio>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
int t;
|
||||
scanf("%d",&t);
|
||||
while(t--)
|
||||
{
|
||||
int n,k;
|
||||
scanf("%d %d",&n,&k);
|
||||
vector<int> vec;
|
||||
int temp;
|
||||
for(int i=0;i<n;i++)
|
||||
{
|
||||
scanf("%d",&temp);
|
||||
vec.push_back(temp);
|
||||
}
|
||||
sort(vec.begin(),vec.end(),greater<int>());
|
||||
int cnt=1;
|
||||
for(int i=0;i<n-1;i++)
|
||||
{
|
||||
if(vec[i]-vec[i+1]<=k) ++cnt;
|
||||
else break;
|
||||
}
|
||||
printf("%d\n",cnt);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user