码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces Round #645 (Div. 2)

时间:2020-05-31 14:30:38      阅读:584      评论:0      收藏:0      [点我收藏+]

标签:target   view   bre   color   src   def   ola   hid   href   

题目传送门

 

A. Park Lighting

技术图片
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (register int i = a; i <= b; i++)

ll n, m;
void solve()
{
    cin >> n >> m;
    cout << (n * m) / 2 + (n * m) % 2 << endl;
}
int main()
{
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
}
View Code

 

B. Maria Breaks the Self-isolation

技术图片
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (register int i = a; i <= b; i++)

ll n, a[100010], ans;
void solve()
{
    cin >> n;
    rep(i, 1, n) cin >> a[i];
    sort(a + 1, a + n + 1);
    ans = 0;
    rep(i, 1, n) if (a[i] <= i) ans = i;
    cout << ans + 1 << endl;
}
int main()
{
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
}
View Code

 

C. Celex Update

技术图片
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (register int i = a; i <= b; i++)

ll xa, xb, ya, yb;
void solve()
{
    cin >> xa >> ya >> xb >> yb;
    cout << (xb - xa) * (yb - ya) + 1 << endl;
}
int main()  
{
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
}
View Code

 

D. The Best Vacation

技术图片
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (register int i = a; i <= b; i++)

ll n, x, d[400010];
ll id, cnt, tmp, ans;
void solve()
{
    cin >> n >> x;
    id = cnt = ans = 0;
    rep(i, 1, n)
    {
        cin >> d[i];
        d[i + n] = d[i];
    }
    rep(i, 1, n * 2)
    {
        cnt += d[i];
        tmp += (d[i] + 1) * d[i] / 2;
        if (cnt >= x)
        {
            while (cnt - x > d[id + 1])
            {
                cnt -= d[++id];
                tmp -= (d[id] + 1) * d[id] / 2;
            }
            ans = max(ans, tmp - (cnt - x + 1) * (cnt - x) / 2);
            cnt -= d[++id];
            tmp -= (d[id] + 1) * d[id] / 2;
        }
    }
    cout << ans << endl;
}
int main()
{
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}
View Code

 

Codeforces Round #645 (Div. 2)

标签:target   view   bre   color   src   def   ola   hid   href   

原文地址:https://www.cnblogs.com/likunhong/p/12992045.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!