2024-2025 ICPC, NERC, Southern and Volga Russian Regional Contest(cf)(个人记录)

发布于:2024-12-08 ⋅ 阅读:(46) ⋅ 点赞:(0)

A:

在这里插入图片描述

思路:一开始有点懵逼,理解错题意了}, 由于是顺序分配,因此前面的人可以选择的条件更多,后面的人更少,我们从后向前遍历即可

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll>PII;
const int N = 2e5 + 10;
const int MOD = 998244353;
const int INF = 0X3F3F3F3F;
const int dx[] = {-1, 1, 0, 0, -1, -1, +1, +1};
const int dy[] = {0, 0, -1, 1, -1, +1, -1, +1};
const int M = 1e9 + 7;

PII p[N];
ll a[N];
ll n, oo;
//越向后选择权越小
int main()
{
	cin >> n >> oo;
	for(int i = 1; i <= n; i ++)
	{
		cin >> p[i].first;
	}
	ll s = 0;
	for(int i = 1; i <= n; i ++)
	{
		cin >> p[i].second;
		s += p[i].first / p[i].second;
	}
	if(s < oo) {
		for(int i = 1; i <= n; i ++)
		{
			cout << 0 << " ";
		}
		cout << endl;
	}
	else {
		ll res = 0;
	    for(int i = n; i >= 1; i --)
		{
			ll o = p[i].first / p[i].second;
			res += o;
			if(res >= oo)
			{
				a[i] = o - (res - oo);
				break;
			}
			else a[i] = p[i].first / p[i].second;
		}
		for(int i = 1; i <= n; i ++) cout << a[i] << ' ';
	}
	return 0;
}

C:

在这里插入图片描述

思路:我们可以知道对于矩形的四个顶点(x1, y1), (x2, y2), (x3, y3), (x4, y4), x1 == x2, x3 == x4, y1 == y3, y2 == y4, 因此我们只需要找出来两两相等的数即可,然后排个序,找出前两个顶点和最后两个顶点即可,此时面积即为最大值

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll>PII;
const int N = 2e5 + 10;
const int MOD = 998244353;
const int INF = 0X3F3F3F3F;
const int dx[] = {-1, 1, 0, 0, -1, -1, +1, +1};
const int dy[] = {0, 0, -1, 1, -1, +1, -1, +1};
const int M = 1e9 + 7;

int t;

ll a[N];
int main()
{
	cin >> t;
	while(t --){
		int n;
		cin >> n;
		map<ll, ll>ma;
		for(int i = 1; i <= n; i ++) 
		{
			ll x;
			cin >> x;
			ma[x] ++;
		}
		int k = 0;
		for(auto it : ma)
		{
			ll i = it.second;
			for(int j = 1; j <= i / 2; j ++) a[++ k] = it.first;
		}
		if(k < 4) cout << "NO" << endl;
		else {
			cout << "YES" << endl;
			ll x1 = a[1], y1 = a[2];
			ll x2 = a[1], y2 = a[k];
			ll x3 = a[k - 1], y3 = a[2];
			ll x4 = a[k - 1], y4 = a[k];
			cout << x1 << " " << y1 << " " << x2 << " " << y2 << ' ' << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
		} 
	}
	return 0;
}

J:

在这里插入图片描述

签到题,直接模拟即可

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll>PII;
const int N = 2e5 + 10;
const int MOD = 998244353;
const int INF = 0X3F3F3F3F;
const int dx[] = {-1, 1, 0, 0, -1, -1, +1, +1};
const int dy[] = {0, 0, -1, 1, -1, +1, -1, +1};
const int M = 1e9 + 7;

int t;

ll a[N];
int main()
{
	cin >> t;
	ll s = 0;
	while(t --){
		char c;
		int x;
		cin >> c >> x;
		if(c == 'P')
		{
			s += x;
		}
		else {
			if(s < x) cout << "YES" << endl;
			else cout << "NO" << endl;
			s -= x;
			s = max((ll)0, s);
		}
	}
	return 0;
}

L:

在这里插入图片描述

思路:(整体分配法)我们的木棍长度为60, 对于18和21, 我们可以这样分配(18, 18, 18)(18, 18, 21)(18, 21, 21), 因此对于前两个能整除3的部分我们直接的求出s1 = 2 * n / 3, 对于有25的部分, 无论如何分配我们最多只能制作2个, 还需要在加上前两个剩余的数即可, s2 = (2 * n % 3 + n + 1) / 2;(向上取整)

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll>PII;
const int N = 2e5 + 10;
const int MOD = 998244353;
const int INF = 0X3F3F3F3F;
const int dx[] = {-1, 1, 0, 0, -1, -1, +1, +1};
const int dy[] = {0, 0, -1, 1, -1, +1, -1, +1};
const int M = 1e9 + 7;

int t;

int main()
{
    //看作成整体后在做即可
	ll n;
	cin >> n;
	cout << n * 2 / 3 + (n * 2 % 3 + 1 + n) / 2 << endl;
	return 0;
}

N:

在这里插入图片描述

签到题, 模拟即可

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll>PII;
const int N = 2e5 + 10;
const int MOD = 998244353;
const int INF = 0X3F3F3F3F;
const int dx[] = {-1, 1, 0, 0, -1, -1, +1, +1};
const int dy[] = {0, 0, -1, 1, -1, +1, -1, +1};
const int M = 1e9 + 7;


int main()
{
    int t;
	cin >> t;
	while(t --){
		string s;
		cin >> s;
		if(s[0] < s[2])
	    	cout << s[0] << '<' << s[2] << endl;
		if(s[0] > s[2])
			cout << s[0] << '>' << s[2] << endl;
		if(s[0] == s[2])
			cout << s[0] << '=' << s[2] << endl;
	}
	return 0;
}