文章目录
- BC149 简写单词
- dd爱框框
- 除2!
BC149 简写单词
BC149 简写单词
#include<iostream>
#include<string>
using namespace std;
string s;
int main()
{
while(cin>>s)
{
if(s[0]>='a'&&s[0]<='z') cout<<char(s[0]-32);
else cout<<s[0];
}
return 0;
}
dd爱框框
dd爱框框
# define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
const int N = 1e7 + 5;
int n, x;
int a[N];
int main()
{
cin >> n >> x;
for (int i = 1; i <= n; i++) cin >> a[i];
int anslen = 0x3f3f3f3f, left = 0, right = 0,sum=0;
int retleft = -1, retright = -1;
while (right <= n)
{
sum += a[right];
while (sum >= x)
{
if (right - left + 1 < anslen)
{
retleft = left;
retright = right;
anslen = right - left + 1;
}
sum -= a[left++];
}
right++;
}
cout << retleft << " " << retright << endl;
return 0;
}
除2!
除2!
#include<iostream>
#include<queue>
using namespace std;
typedef long long ll;
ll n, k;
priority_queue<ll> heap;
int main()
{
cin >> n >> k;
ll x, sum = 0;
while (n--)
{
cin >> x;
sum += x;
if (x % 2 == 0) heap.push(x);
}
while (heap.size() && k--)
{
ll t = heap.top() / 2;
heap.pop();
sum -= t;
if (t % 2 == 0) heap.push(t);
}
cout << sum << endl;
return 0;
}