249 条题解
-
0JimmyChen LV 8 @ 2017-06-18 12:20:22
太粗心了,醉
#include <cstdio> #include <iostream> #include <algorithm> using namespace std; int c = 0; bool down(int a, int b){ return a > b; } int main(){ int n = 0, m = 0; cin >> n >> m; int apples[n], tt[m]; for (int i = 0; i < n; i++) cin >> apples[i]; for (int i = 0; i < m; i++) cin >> tt[i]; sort(tt, tt + m, down); sort(apples, apples + n, down); for (int i = 0; i < n; i++){ for (int j = 0; j < m; j++){ if (tt[j] < apples[i] && tt[j] > 0){ tt[j] = -1; break; } } } for (int i = 0; i < m; i++){ if (tt[i] != -1) c++; } cout << c << endl; return 0; }
-
02017-05-13 19:59:51@
也就那样吧 c++的
#include<iostream>
#include<cstdio>using namespace std;
const int maxn = 2005;
int apple[maxn];
int taotao[2000];int main(){
int n,m;
cin >> n >> m;
for(int i = 1; i < n+1;i++){
cin >> apple[i];
}
for(int i = 1; i < m+1;i++){
cin >> taotao[i];
}
for(int i = 1; i < m+1;i++){
for(int j = i+1;j < m+1;j++){
if(taotao[i] > taotao[j]){
int temp = taotao[i];
taotao[i] = taotao[j];
taotao[j] = temp;
}
}
}
for(int i = 1;i < n+1; i++){
for(int j = i+1 ;j< n +1 ; j++){
if(apple[i] > apple[j]){
int temp = apple[i];
apple[i] = apple[j];
apple[j] = temp;
}
}
}
for(int i = n;i > 0;i--){
for(int j = m;j > 0;j--){
if(apple[i] > taotao[j] && taotao[j] > 0){
taotao[j]=-1;
break;
}
}
}
int counter = 0;
for(int i = 1;i <= m;i++){
if(taotao[i]!=-1){
counter++;
}
}
cout<<counter<<endl;
return 0 ;
} -
02017-02-28 05:39:07@
#include <stdio.h>
int main()
{
int i,j,n,m,sum=0,temp1=0,temp2=0;
scanf("%d %d",&n,&m);
int nn[n],mm[m];
for (i=0;i<n;i++)scanf("%d",&nn[i]);
for (i=0;i<m;i++)scanf("%d",&mm[i]);
for (j=0;j<m;j++) if (mm[j]==0) sum++;
for (i=0;i<n;i++)
{
temp1=0;temp2=-1;
for (j=0;j<m;j++)
if(nn[i]>mm[j]&&mm[j]!=0&&mm[j]>=temp1)
{
temp1=mm[j];temp2=j;
}
if (temp2!=-1) mm[temp2]=0;
//for (j=0;j<m;j++) printf("%d ",mm[j]);printf("\n");}
for (i=0;i<m;i++) if (mm[i]!=0) sum++;
printf("%d\n",sum);
return 0;
} -
02017-02-16 09:53:19@
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;int n,m;
vector<int>a,b;int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
int x;scanf("%d",&x);
a.push_back(x);
}
for(int i=1;i<=m;i++){
int x;scanf("%d",&x);
if(x!=0)b.push_back(x);
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
int i=a.size()-1,j=b.size()-1,ans=0;
while(i>=0&&j>=0){
if(a[i]>b[j])i--,ans++;
j--;
}
cout<<m-ans;
}#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;int n,m;
vector<int>a,b;int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
int x;scanf("%d",&x);
a.push_back(x);
}
for(int i=1;i<=m;i++){
int x;scanf("%d",&x);
if(x!=0)b.push_back(x);
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
int i=a.size()-1,j=b.size()-1,ans=0;
while(i>=0&&j>=0){
if(a[i]>b[j])i--,ans++;
j--;
}
cout<<m-ans;
}#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;int n,m;
vector<int>a,b;int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
int x;scanf("%d",&x);
a.push_back(x);
}
for(int i=1;i<=m;i++){
int x;scanf("%d",&x);
if(x!=0)b.push_back(x);
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
int i=a.size()-1,j=b.size()-1,ans=0;
while(i>=0&&j>=0){
if(a[i]>b[j])i--,ans++;
j--;
}
cout<<m-ans;
} -
02017-01-28 12:03:03@
评测结果
编译成功测试数据 #0: Accepted, time = 15 ms, mem = 748 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 744 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 748 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 748 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 748 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 748 KiB, score = 10
测试数据 #6: Accepted, time = 15 ms, mem = 748 KiB, score = 10
测试数据 #7: Accepted, time = 15 ms, mem = 748 KiB, score = 10
测试数据 #8: Accepted, time = 15 ms, mem = 744 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 748 KiB, score = 10
Accepted, time = 60 ms, mem = 748 KiB, score = 100
代码
#include <iostream>
#include <algorithm>
using namespace std;
int x1[2000],x2[2000];
int main()
{
int a,b,s=0;
cin>>a>>b;
for(int i=1;i<=a;i++)
cin>>x1[i];
for(int j=1;j<=b;j++)
cin>>x2[j];
sort(x1+1,x1+a+1);
sort(x2+1,x2+b+1);
for(int i=a;i>0;i--)
for(int j=b;j>=1;j--)
if(x1[i]>x2[j]&&x2[j]!=-1&&x2[j])
{
x2[j]=-1;
break;
}
for(int i=1;i<=b;i++)
if(x2[i]!=-1)
s++;
cout<<s;
}
-
02016-12-29 08:11:59@
var n,m,i,j,q,s:longint;
a,b:array[1..10000] of longint;
begin
readln(n,m);
for i:=1 to n do readln(a[i]);
for i:=1 to m do readln(b[i]);
for i:=1 to m-1 do
for j:=1 to m-i do
if b[j]>b[j+1] then
begin
s:=b[j];
b[j]:=b[j+1];
b[j+1]:=s;
end;
i:=0; q:=0;
repeat
inc(i);
for j:=m downto 1 do
if (a[i]>b[j])and(b[j]<>-1)and(b[j]<>0) then
begin
inc(q);b[j]:=-1;
break;
end;
until i=n;
q:=m-q;
writeln(q);
end.
更短一些 -
02016-11-13 12:09:27@
排一下序。。然后尽可能的让高的苹果去摘高的人。。。记得把高为0的人删掉。。
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;int n,m;
vector<int>a,b;int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
int x;scanf("%d",&x);
a.push_back(x);
}
for(int i=1;i<=m;i++){
int x;scanf("%d",&x);
if(x!=0)b.push_back(x);
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
int i=a.size()-1,j=b.size()-1,ans=0;
while(i>=0&&j>=0){
if(a[i]>b[j])i--,ans++;
j--;
}
printf("%d\n",m-ans);
} -
02016-10-31 21:40:59@
桶排!!!
var
n,m:longint;
a:array[1..2005]of longint;
b:array[0..300]of longint;procedure init;
var
i,k:longint;
begin
readln(n,m);
fillchar(b,sizeof(b),0);
fillchar(a,sizeof(a),0);
for i:=1 to n do readln(a[i]);
for i:=1 to m do
begin
readln(k);
inc(b[k]);
end;
end;procedure main;
var
i,ans:longint;
begin
ans:=0;
for i:=1 to n do
begin
dec(a[i]);//只能摘最大高度以下的苹果
while b[a[i]]=0 do dec(a[i]);
** if a[i]=0 then continue;**//高度为零的苹果不能摘,555,因为忘了这个,WA了7次
dec(b[a[i]]);
end;
for i:=0 to 300 do inc(ans,b[i]);
writeln(ans);
end;begin
init;
main;
end. -
02016-09-01 19:24:15@
方晨羽——福利站(pascal)
pascal
var
a,b:array[1..2000]of longint;
n,m,i,j,t:longint;
begin
readln(n,m);
for i:=1 to n do read(a[i]);
readln;
for i:=1 to m do read(b[i]);
readln;
for i:=1 to m-1 do
for j:=i+1 to m do
if b[i]<b[j]
then
begin
t:=b[i];
b[i]:=b[j];
b[j]:=t;
end;
for i:=1 to n do
for j:=1 to m do
if (b[j]>0) and (b[j]<a[i])
then
begin
b[j]:=-1;
break;
end;
t:=0;
for i:=1 to m do
if b[i]>=0 then inc(t);
writeln(t);
end.
-
02016-07-16 11:47:02@
c++算法
#include <iostream>
#include <cstdio>
#include<algorithm>
using namespace std;
//bool cmp(int a,int b){
//return a>b;//降序
//return a>b;升序 }
int main(){
int n,m;
cin>>n>>m;
int i,j;
int ni[2010]={0};
int mi[2010]={0};
for(i=1;i<=n;i++){
cin>>ni[i];
}
for(i=1;i<=m;i++){
cin>>mi[i];
}
sort(mi+1,mi+m+1//,cmp);
int x=m;
int k;
for(i=1;i<=n;i++){
for(k=m;k>=1;k--){
if(ni[i]>mi[k]&&mi[k]!=0){
mi[k]=0;
x--;
break;
}
}
}
cout<<x;
return 0;
} -
02016-07-15 15:24:06@
AC100
var a,b:array[1..2000]of longint; n,m,i,j,t:longint; begin readln(n,m); for i:=1 to n do read(a[i]); for i:=1 to m do read(b[i]); for i:=1 to m-1 do for j:=i+1 to m do if b[i]<b[j] then begin t:=b[i];b[i]:=b[j];b[j]:=t;end; for i:=1 to n do for j:=1 to m do if (b[j]>0)and(b[j]<a[i]) then begin b[j]:=-1;break;end; t:=0; for i:=1 to m do if b[i]>=0 then inc(t); writeln(t); end.
-
02016-03-21 07:59:24@
##include <iostream>
##include <stdio.h>
##include <algorithm>
using namespace std;int n,m,a[2010],t[2010];
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
for(int i=1;i<=m;i++)
scanf("%d",&t[i]);
int left=m;
sort(t+1,t+m+1);
for(int i=1;i<=n;i++)
{
for(int j=m;j>0;j--)
{
if(a[i]>t[j]&&t[j]!=0)
{
t[j]=0;
left--;
break;
}
}
}
printf("%d",left);
} -
02016-02-21 21:02:17@
记录信息
评测状态 Accepted
题目 P1291 苹果摘陶陶
递交时间 2015-10-07 20:36:08
代码语言 Pascal
评测机 VijosEx
消耗时间 174 ms
消耗内存 864 KiB
评测时间 2015-10-07 20:36:08
评测结果
编译成功Free Pascal Compiler version 2.6.4 [2014/03/06] for i386
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling foo.pas
Linking foo.exe
37 lines compiled, 0.1 sec , 28480 bytes code, 1628 bytes data
测试数据 #0: Accepted, time = 0 ms, mem = 864 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 864 KiB, score = 10
测试数据 #2: Accepted, time = 31 ms, mem = 864 KiB, score = 10
测试数据 #3: Accepted, time = 15 ms, mem = 860 KiB, score = 10
测试数据 #4: Accepted, time = 15 ms, mem = 860 KiB, score = 10
测试数据 #5: Accepted, time = 31 ms, mem = 856 KiB, score = 10
测试数据 #6: Accepted, time = 31 ms, mem = 860 KiB, score = 10
测试数据 #7: Accepted, time = 31 ms, mem = 860 KiB, score = 10
测试数据 #8: Accepted, time = 16 ms, mem = 860 KiB, score = 10
测试数据 #9: Accepted, time = 4 ms, mem = 864 KiB, score = 10
Accepted, time = 174 ms, mem = 864 KiB, score = 100
代码
var a,b:array[1..10000]of longint;
c,d:array[1..10000]of boolean;
n,m,i,j,k,max:longint;
begin
max:=0;
fillchar(c,sizeof(c),true);
d:=c;
readln(n,m);
for i:=1 to n do readln(a[i]);
for i:=1 to m do readln(b[i]);
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]<a[j] then begin k:=a[i]; a[i]:=a[j]; a[j]:=k; end; for i:=1 to m-1 do for j:=i+1 to m do if b[i]<b[j] then begin k:=b[i]; b[i]:=b[j]; b[j]:=k; end; for i:=1 to n do for j:=1 to m do if b[j]>0 then
if (a[i]>b[j])and(c[i])and(d[j])then
begin
inc(max);
c[i]:=false;
d[j]:=false;
break;
end;
writeln(m-max);
end.
! -
02015-12-23 12:39:21@
water water water water water water water water water water water water water water water water water water water water water water water water water
-
02015-12-22 15:32:50@
测试数据 #0: Accepted, time = 15 ms, mem = 292 KiB, score = 10
测试数据 #1: Accepted, time = 15 ms, mem = 292 KiB, score = 10
测试数据 #2: Accepted, time = 31 ms, mem = 288 KiB, score = 10
测试数据 #3: Accepted, time = 15 ms, mem = 292 KiB, score = 10
测试数据 #4: Accepted, time = 15 ms, mem = 292 KiB, score = 10
测试数据 #5: Accepted, time = 31 ms, mem = 288 KiB, score = 10
测试数据 #6: Accepted, time = 46 ms, mem = 288 KiB, score = 10
测试数据 #7: Accepted, time = 31 ms, mem = 292 KiB, score = 10
测试数据 #8: Accepted, time = 15 ms, mem = 292 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 292 KiB, score = 10
Accepted, time = 214 ms, mem = 292 KiB, score = 100
代码:
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int a[2005],b[2005];
int main()
{
int n,m;
cin>>n>>m;
for(int j=1;j<=n;j++)
cin>>a[j];
for(int j=1;j<=m;j++)
cin>>b[j];
sort(b+1,b+m+1);
int x=m;
for(int j=1;j<=n;j++)
{
for(int k=m;k>=1;k--)
{
if(a[j]>b[k]&&b[k]!=0)
{
b[k]=0;
x--;
break;
}
}
}
cout<<x;
} -
02015-10-07 20:39:53@
坑太深了!!!!!!!!!!啊哈啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊和哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
-
02015-10-07 20:39:28@
记录信息
评测状态 Accepted
题目 P1291 苹果摘陶陶
递交时间 2015-10-07 20:36:08
代码语言 Pascal
评测机 VijosEx
消耗时间 174 ms
消耗内存 864 KiB
评测时间 2015-10-07 20:36:08
评测结果
编译成功Free Pascal Compiler version 2.6.4 [2014/03/06] for i386
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling foo.pas
Linking foo.exe
37 lines compiled, 0.1 sec , 28480 bytes code, 1628 bytes data
测试数据 #0: Accepted, time = 0 ms, mem = 864 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 864 KiB, score = 10
测试数据 #2: Accepted, time = 31 ms, mem = 864 KiB, score = 10
测试数据 #3: Accepted, time = 15 ms, mem = 860 KiB, score = 10
测试数据 #4: Accepted, time = 15 ms, mem = 860 KiB, score = 10
测试数据 #5: Accepted, time = 31 ms, mem = 856 KiB, score = 10
测试数据 #6: Accepted, time = 31 ms, mem = 860 KiB, score = 10
测试数据 #7: Accepted, time = 31 ms, mem = 860 KiB, score = 10
测试数据 #8: Accepted, time = 16 ms, mem = 860 KiB, score = 10
测试数据 #9: Accepted, time = 4 ms, mem = 864 KiB, score = 10
Accepted, time = 174 ms, mem = 864 KiB, score = 100
代码
var a,b:array[1..10000]of longint;
c,d:array[1..10000]of boolean;
n,m,i,j,k,max:longint;
begin
max:=0;
fillchar(c,sizeof(c),true);
d:=c;
readln(n,m);
for i:=1 to n do readln(a[i]);
for i:=1 to m do readln(b[i]);
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]<a[j] then
begin
k:=a[i];
a[i]:=a[j];
a[j]:=k;
end;
for i:=1 to m-1 do
for j:=i+1 to m do
if b[i]<b[j] then
begin
k:=b[i];
b[i]:=b[j];
b[j]:=k;
end;
for i:=1 to n do
for j:=1 to m do
if b[j]>0 then
if (a[i]>b[j])and(c[i])and(d[j])then
begin
inc(max);
c[i]:=false;
d[j]:=false;
break;
end;
writeln(m-max);
end.AC40留念!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈和哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈和哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
02015-09-23 00:47:33@
有人给看看吗,一个20,一个100。why????无语了!!!!
#include <iostream>
#include <algorithm>using namespace std;
int n,m;
int i,j;int main()
{
cin>>n>>m;
int apple[n];
int taotao[m];
for(i=0;i<n;++i)
{
cin>>apple[i];
}
for(i=0;i<m;++i)
{
cin>>taotao[i];
}
sort(taotao,taotao+m);
for(i=0;i<n;++i)
{
for(j=m-1;j>=0;j--)
{
if(taotao[j]<apple[i]&&taotao[j]>0)
{
taotao[j]=-1;
m--;
break;
}
}
}
cout<<m;
return 0;
}#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;int n,m,a[2010],t[2010];
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
for(int i=1;i<=m;i++)
scanf("%d",&t[i]);
int left=m;
sort(t+1,t+m+1);
for(int i=1;i<=n;i++)
{
for(int j=m;j>0;j--)
{
if(a[i]>t[j]&&t[j]!=0)
{
t[j]=0;
left--;
break;
}
}
}
printf("%d",left);
} -
02015-07-27 09:13:07@
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;int n,m,a[2010],t[2010];
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
for(int i=1;i<=m;i++)
scanf("%d",&t[i]);
int left=m;
sort(t+1,t+m+1);
for(int i=1;i<=n;i++)
{
for(int j=m;j>0;j--)
{
if(a[i]>t[j]&&t[j]!=0)
{
t[j]=0;
left--;
break;
}
}
}
printf("%d",left);
} -
02015-05-31 11:27:55@
program zdfei;
var
k:array[0..303]of integer;
s:array[0..2003]of integer;
n,m,i,j,a:integer;
begin
readln(n,m);
for i:=1 to n do readln(s[i]);
for i:=1 to m do
begin
readln(a);k[a]:=k[a]+1;
end;
a:=0;
for i:=1 to n do
for j:=s[i]-1 downto 1 do
if k[j]>0 then
begin
k[j]:=k[j]-1;break;
end;
for i:=0 to 300 do
a:=a+k[i];
writeln(a);
end.