Skip to content
Narrow screen resolution Wide screen resolution Auto adjust screen size Increase font size Decrease font size Default font size default color grey color
         
 | 
VNOI - Olympic tin học Việt Nam

Điểm tin VOJ

Số thành viên:6040
Số bài tập:1001
Số bài nộp:722923
Bài nộp hôm nay:0

Top 10 thành viên xuất sắc

HạngThành viênĐiểm
1mr_invincible587.9
2white_cobra418.6
3hieult403.4
4phaleq384.0
5vodanh9x368.2
6con_nha_ngheo352.0
7flash_mt350.2
8darksabers349.8
9yenthanh132345.3
10rockman9x_94343.1

Danh tiếng các thành viên

HạngThành viênĐiểm
1mr_invincible+213
2conankudo+149
3khuc_tuan+137
4tuananhnb93+129
5khanhptnk+108
6hphong+103
7flash_mt+99
8paulmcvn+71
9technolt+70
10hoangle+63

Topcoder Vietnam

HạngThành viênĐiểm
Diễn đàn
Forum
Trả lời: LQDFARM (1 đang xem) ,(1) Khách
Bài viết dưới cùng Gửi trả lời Được ưa thích: 0
CHỦ ĐỀ - Trả lời: LQDFARM
#70551
darkzero (Thành viên)
Đang tập code
Bài viết: 1
graphgraph
Thành viên gián tuyến Click vào đây để xem thông tin về thành viên này
Trả lời: LQDFARM 7 năm, 6 tháng trước   (+0)
mọi người ơi xem hộ bài em sai chỗ nào với
ý tưởng của em là tham lam sau cho q nhỏ bớt sau đó quy hoạch động cuối cùng tham lam tiếp ko biết sai chỗ nào
em xin cảm ơn
Code:
 
uses math;
var A,B: array [1..2000] of longint;
    F: array [1..4000] of boolean;
    L: array [0..2000,0..10000000] of longint;
    Q,M,K,H: longint;
procedure Nhapdl;
var i: longint;
begin
   read(Q,M,K);H:=M;
   for i:=1 to M do
   read(A[i]);
   for i:=1 to K do
   read(B[i]);
end;
procedure sort(l,r:longint);
var tg1,tg,i,j:longint;
   begin
      if l>=r then exit;
      tg:=a[(l+r) div 2];
      i:=l;j:=r;
      repeat
         while a[i]<tg do inc(i);
         while a[j]>tg do dec(j);
         if i<=j then
            begin
               tg1:=a[i];
               a[i]:=a[j];
               a[j]:=tg1;
               inc(i);
               dec(j);
            end;
      until i>j;
      sort(l,j);
      sort(i,r);
   end;
procedure   sort1(l,r:longint);
   var tg,tg1,i,j:longint;
   begin
      if l>=r then exit;
      i:=l; j:=r;
      tg:=b[(i+j) div 2];
      repeat
         while b[i]<tg do inc(i);
         while b[j]>tg do dec(j);
         if i<=j then
            begin
               tg1:=b[i];
               b[i]:=b[j];
               b[j]:=tg1;
               inc(i);
               dec(j);
            end;
      until i>j;
      sort1(l,j); sort1(i,r);
   end;
procedure Solve;
var i,j,tong,x,cs: longint;
begin
   sort(1,M);
   tong:=0;
   while q>a[M] do
   begin
      tong:=tong+a[M];
      q:=q-a[M];
      F[M]:=TRUE;
      dec(M);
   end;
   for i:=0 to M do
      for j:=0 to Q do L[i,j]:=0;
   for i:=1 to M do
      for j:=1 to q do
         if a[i]<=j then L[i,j]:=max(L[i-1,j],L[i-1,j-a[i]]+a[i])
         else L[i,j]:=L[i-1,j];
   x:=0;
   for j:=1 to q do
      if x<L[M,j] then
      begin
         x:=L[M,j];
         cs:=j;
      end;
   j:=cs;
   tong:=tong+x;
   for i:=M downto 1 do
   if L[i,j]<>L[i-1,j] then
   begin
      j:=j-a[i];
      F[i]:=TRUE;
      q:=q-a[i];
   end;
   i:=1;
   while (q>a[i]) do
      if F[i] then inc(i)
      else
         begin
            tong:=tong+a[i];
            q:=q-a[i];
            inc(i);
         end;
   if i<=H then tong:=tong+q-1
   else
   begin
      sort(1,K);i:=1;
      while q>b[i] do
      begin
         tong:=tong+b[i]-1;
         q:=q-b[i];
         inc(i);
      end;
      if i<=K then tong:=tong+q-1;
   end;
   writeln(tong);
end;
BEGIN
   nhapdl;
   Solve;
END.
 
Đã lưu IP Đã lưu IP  
  Đã khóa chức năng gửi bài.
      Chủ đề Tác giả Ngày
    thread link
LQDFARM
phúc_ngồ 12/06/2011 11:55
    thread link
thread linkthread link Trả lời: LQDFARM
Chicharito 12/06/2011 12:19
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
pro4minh 12/06/2011 12:59
    thread link
thread linkthread link Trả lời: LQDFARM
GiongTo35 12/06/2011 12:58
    thread link
thread linkthread link Trả lời: LQDFARM
whatsgoingon 12/06/2011 20:11
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
sirdat_LS 12/06/2011 20:23
    thread link
thread linkthread linkthread linkthread link Trả lời: LQDFARM
pro4minh 12/06/2011 21:13
    thread link
thread linkthread link Trả lời: LQDFARM
whatsgoingon 12/06/2011 21:30
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
Nguyen_Duy_Khanh 12/06/2011 23:05
    thread link
thread linkthread link Trả lời: LQDFARM
GiongTo35 12/06/2011 23:22
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
HNUE_D 13/06/2011 01:01
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
pro4minh 13/06/2011 01:02
    thread link
thread linkthread linkthread linkthread link Trả lời: LQDFARM
HNUE_D 13/06/2011 01:05
    thread link
thread linkthread linkthread linkthread link Trả lời: LQDFARM
pro4minh 13/06/2011 01:07
    thread link
thread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
HNUE_D 13/06/2011 01:09
    thread link
thread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
pro4minh 13/06/2011 01:14
    thread link
thread linkthread linkthread linkthread link Trả lời: LQDFARM
Nguyen_Duy_Khanh 13/06/2011 05:14
    thread link
thread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
EternalAutumn 13/06/2011 07:35
    thread link
thread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
iamquang95 13/06/2011 07:43
    thread link
thread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
GiongTo35 13/06/2011 07:49
    thread link
thread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
Nguyen_Duy_Khanh 13/06/2011 08:20
    thread link
thread linkthread link Trả lời: LQDFARM
GiongTo35 13/06/2011 08:34
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
iamquang95 13/06/2011 08:41
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
franco 13/06/2011 09:56
    thread link
thread linkthread linkthread linkthread link Trả lời: LQDFARM
pro4minh 13/06/2011 10:03
    thread link
thread linkthread linkthread linkthread link Trả lời: LQDFARM
GiongTo35 13/06/2011 10:14
    thread link
thread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
blackstart 13/06/2011 10:18
    thread link
thread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
franco 13/06/2011 10:19
    thread link
thread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
Wayner Rooney 13/06/2011 11:08
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
iamquang95 13/06/2011 21:21
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
Nguyen_Duy_Khanh 13/06/2011 21:31
    thread link
thread linkthread link Trả lời: LQDFARM
GiongTo35 13/06/2011 08:44
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
Nguyen_Duy_Khanh 13/06/2011 08:52
    thread link
thread linkthread link Trả lời: LQDFARM
haplinhavxt 13/06/2011 10:24
    thread link
thread linkthread link Trả lời: LQDFARM
haplinhavxt 13/06/2011 21:40
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
pro4minh 13/06/2011 21:45
    thread link
thread linkthread linkthread linkthread link Trả lời: LQDFARM
iamquang95 13/06/2011 22:27
    thread link
thread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
Wayner Rooney 13/06/2011 22:44
    thread link
thread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
pro4minh 14/06/2011 00:02
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
Wayner Rooney 14/06/2011 00:18
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
blackstart 14/06/2011 00:22
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
pro4minh 14/06/2011 00:24
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
EternalAutumn 14/06/2011 05:59
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
franco 14/06/2011 06:43
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
iamquang95 14/06/2011 06:49
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
sirdat_LS 14/06/2011 06:50
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
EternalAutumn 14/06/2011 07:21
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
franco 14/06/2011 07:28
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
Nguyen_Duy_Khanh 14/06/2011 07:35
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
Nguyen_Duy_Khanh 14/06/2011 20:27
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
thaoing 14/06/2011 20:37
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
langson1995 14/06/2011 22:29
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
Wayner Rooney 14/06/2011 22:54
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
pro4minh 15/06/2011 01:45
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
sirdat_LS 15/06/2011 20:59
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
langson1995 15/06/2011 21:44
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
pro4minh 16/06/2011 04:03
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
sirdat_LS 16/06/2011 04:07
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
GiongTo35 16/06/2011 05:59
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
sirdat_LS 16/06/2011 06:04
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
langson1995 15/06/2011 20:39
    thread link
thread linkthread link Trả lời: LQDFARM
GiongTo35 13/06/2011 21:45
    thread link
thread linkthread link Trả lời: LQDFARM
manh1208 14/06/2011 00:21
    thread link
thread linkthread link Trả lời: LQDFARM
Mashimaru 14/06/2011 00:52
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
pro4minh 14/06/2011 01:03
    thread link
thread linkthread link Trả lời: LQDFARM
GiongTo35 14/06/2011 01:02
    thread link
thread linkthread link Trả lời: LQDFARM
blackstart 14/06/2011 01:44
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
pro4minh 14/06/2011 01:49
    thread link
thread linkthread linkthread linkthread link Trả lời: LQDFARM
blackstart 14/06/2011 02:12
    thread link
thread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
thai19995 14/06/2011 03:57
    thread link
thread linkthread link Trả lời: LQDFARM
GiongTo35 14/06/2011 08:03
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
EternalAutumn 14/06/2011 08:11
    thread link
thread linkthread link Trả lời: LQDFARM
manh1208 14/06/2011 09:30
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
thaoing 14/06/2011 09:40
    thread link
thread linkthread link Trả lời: LQDFARM
haplinhavxt 14/06/2011 09:49
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
franco 14/06/2011 10:05
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
mr_pi 12/10/2011 08:18
    thread link
thread linkthread linkthread linkthread link Trả lời: LQDFARM
darkzero 28/01/2013 09:12
    thread link
thread linkthread link Trả lời: LQDFARM
manh1208 14/06/2011 10:12
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
franco 14/06/2011 10:29
    thread link
thread linkthread link Trả lời: LQDFARM
GiongTo35 14/06/2011 10:34
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
pro4minh 14/06/2011 10:40
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
Nguyen_Duy_Khanh 26/06/2011 04:02
    thread link
thread linkthread linkthread linkthread link Trả lời: LQDFARM
Nguyen_Duy_Khanh 26/06/2011 11:02
    thread link
thread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
dhkhtn 29/06/2011 07:24
    thread link
thread linkthread linkthread linkthread linkthread linkthread link Trả lời: LQDFARM
haplinhavxt 29/06/2011 07:50
    thread link
thread linkthread link Trả lời: LQDFARM
manh1208 14/06/2011 10:46
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
pro4minh 14/06/2011 12:01
    thread link
thread linkthread link Trả lời: LQDFARM
haplinhavxt 15/06/2011 22:43
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
sirdat_LS 15/06/2011 23:02
    thread link
thread linkthread link Trả lời: LQDFARM
haplinhavxt 15/06/2011 23:06
    thread link
thread linkthread linkthread link Trả lời: LQDFARM
langson1995 15/06/2011 23:38
    thread link
thread linkthread linkthread linkthread link Trả lời: LQDFARM
EternalAutumn 16/06/2011 00:55
    thread link
thread linkthread link Trả lời: LQDFARM
haplinhavxt 16/06/2011 08:12
Bài viết trên cùng Gửi trả lời
Powered by FireBoardBài viết mới nhất từ diễn đàn cho các chương trình nhận tin RSS