1 条题解
-
0
C++ :
#include<bits/stdc++.h> using namespace std; int a[110],b[25]; bool cmp(int x,int y){ return x>y; } int main(){ int n,m; cin>>n>>m; for(int i=1;i<=n;i++) cin>>a[i]; sort(a+1,a+1+n,cmp); for(int i=1;i<=m;i++) cin>>b[i]; sort(b+1,b+1+n,cmp); int k=1; int sum=0,t=0; for(int i=1;i<=m;i++) for(int j=k;j<=n;j++){ if(b[i]>a[j]){ sum++; t++; } if(t==2){ t=0; k=j+1; break; } } cout<<sum<<endl; return 0; }
Pascal :
var n,m,k,t,j,tmp,sum,i:longint; pg,xpy:array[1..100] of longint; begin readln(n,m); for i:=1 to n do read(pg[i]); for i:=1 to m do read(xpy[i]); for i:=1 to n-1 do for j:=i+1 to n do if pg[i]<pg[j] then begin tmp:=pg[i];pg[i]:=pg[j];pg[j]:=tmp; end; for i:=1 to m-1 do for j:=i+1 to n do if xpy[i]<xpy[j] then begin tmp:=xpy[i];xpy[i]:=xpy[j];xpy[j]:=tmp; end; k:=1; for i:=1 to m do for j:=k to n do if xpy[i]>pg[j] then begin inc(sum); inc(t); if t=2 then begin t:=0; k:=j+1; break; end; end; write(sum); end.
- 1
信息
- ID
- 387
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 10
- 标签
- 递交数
- 1
- 已通过
- 1
- 上传者