跳到正文

个人记录

【LGR-155-Div.3】洛谷基础赛赛后反馈

mhx_zzz约 3 分钟
原文
文章信息与版本

文章信息

发布
2023年8月20日
收录
2025年12月12日
更新
2026年11月14日
篇幅
约 3 分钟

版本

  1. v1当前

T1

最好打的一道题,竟因为我的多此一举,葬送了10分! 90pts:

C++
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1e5+7;
struct nod{
	int t,h;
}a[N];
int b[N];
int main(){
	int n,T,ma=-1,hh;
	cin>>n>>T;
	for(int i=1;i<=n;i++){
		cin>>a[i].h>>a[i].t;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=T;j++){
			if(j==a[i].t){
				b[i]=(T-j)*a[i].h;
				break;
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(b[i]>ma){
			ma=b[i];
			hh=i;
		}
	}
	cout<<hh;
	return 0;
}

100pts:

C++
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1e5+7;
struct nod{
	int t,h;
}a[N];
int b[N];
int main(){
	int n,T,ma=-1,hh;
	cin>>n>>T;
	for(int i=1;i<=n;i++){
		cin>>a[i].h>>a[i].t;
	}
	for(int i=1;i<=n;i++){
		b[i]=(T-a[i].t)*a[i].h;
	}
	for(int i=1;i<=n;i++){
		if(b[i]>ma){
			ma=b[i];
			hh=i;
		}
	}
	cout<<hh;
	return 0;
}

就差了一行!!!

T2

为数不多得分的题,打挂的暴力:

C++
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1e5+7;
char a[N];
bool v[N];
int main(){
	int d,m,n=0,y=0;
	cin>>d>>m;
	for(int i=1;i<=m;i++){
		cin>>a[i];
		if(a[i]=='N') n++;
		else y++;
	}
	if(y==m){
		cout<<"No solution";
		return 0;
	}
	if(n>d){
		cout<<"No solution";
		return 0;
	}
	for(int i=1;i<=m;i++){
		if(a[i]=='N'){
			for(int j=1;j<=d;j++){
				if(v[j]==0){
					cout<<j<<" ";
					v[j]=1;
					break;
				}
			}
		}
		if(a[i]=='Y'){
			for(int i=1;i<=n;i++){
				if(v[i]==1){
					cout<<i<<" ";
					break;
				}
			}
		}
	}
	return 0;
}

T3、4

没啥好讲的,不会,骗骗分得了

原文