T1
最好打的一道题,竟因为我的多此一举,葬送了10分! 90pts:
#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:
#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
为数不多得分的题,打挂的暴力:
#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
没啥好讲的,不会,骗骗分得了