|
|
Common BoardOr should we have our program do all calculations? I got TL although i'm using the binary tree , and when I looked for a solution on the net i found the same of mine but in another words here is my code: #include <cstdio> #include <cstring> using namespace std; #define max 32002 int a[max]; void update(int i,int n,int v) { while(i<=n) { a[i]+=v; i+=i&(-i); } } int read(int i) { int v=0; while(i>0) { v+=a[i]; i-=i&(-i); } return v; } int main() { int n; scanf("%d",&n);
int b[15010]; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); for(int i=1;i<=n;i++) { int x,y; scanf("%d %d",&x,&y);
b[read(x)]++; update(x,32002,1); } for(int i=0;i<n;i++) printf("%d \n",b[i]); return 0; } so please help me cause i'm about to lose my mind!!! x and y can be 0; but you are using a 1 indexed FenwickTree! so your update goes on indefinitely! 0 0 5 0 6 1 1 1 Answer: 0 My solution gives right answer on this test, but I still WA on test #4 :( Fixed, now WA 7. PS. Forget it, it was fail of my code. Now AC. Edited by author 04.05.2015 02:54 Edited by author 04.05.2015 16:49 Sandro't have anywhere to teleport him to stay in the point (0;0). Simply calculate the distance of most distant demon! First digit of the numbers will start from 1 and end with non-zero digit.and there will not present any successive zero. Edited by moderator 23.08.2020 01:25 For example I'm going to enter "40". Your program shows "2225", though should have been seen something like "58". If I understood the clause right. var a:array[1..15000] of integer; i:integer; m,n,k:integer; b:array[1..1000000] of longint; j:integer; Begin k:=0; readln(n); for i:=1 to n do read(a[i]); readln(m); for j:=1 to m do readln(b[j]); for i:=1 to n do for j:=1 to m do if b[j]=a[i] then k:=k+1; writeln(k); end. 2 22 22 4 22 22 22 22 Because your answer is 8? why authors didn't rejudge??? some authors got accepted more than 0.5 sec.... i don't understand why? 1+sqrt(2) Edited by author 26.06.2015 05:22 I've just looked through the submission list. Almost everyone had WA #11. Maybe someone with AC can give me some hint about it? Ok, WA #11 is all about TLE Can somebody give some hints about that test? My mistake. Forget to add two registers (M and N). Dont have any idea how that happened XD Dear All, I am a student and I got an assignment from my teacher to run "1409 Two Gangsters". I write Python program v.2.7 as per following codes. I run the program many times, but it still showed "Runtime Error". I could not fix it. It would be appreciated if someone can help me. Thanks. # 1409 Two Gangsters (Created: 24th June 2015 / Python 2.7) # -------------------- Start of Program -------------------- # # Set initial values total = 0 # total number of cans shot by Harry and Larry Harry = 0 # the number of cans shot by Harry Larry = 0 # the number of cans shot by Larry h = 0 # the number of cans that were not shot by Harry l = 0 # the number of cans that were not shot by Larry Harry = int(input("Please enter the number of cans shot by Harry: ") Larry = int(input("Please enter the number of cans shot by Larry: ")
# Calculation of "The number of cans that were not shot by Harry and Larry" total = Harry + Larry -1 h = total - Harry l = total - Larry # Output print "-"*100 print "Total number of cans are : ", total print "The number of cans that were not shot by Harry and Larry are ", h, "and", l, "respectively." print "-"*100 # -------------------- End of Program -------------------- # My code got WA7. const Nmax=100500; var Dp:array[1..Nmax] of longint; A,V:array[1..Nmax] of longint; N,i:longint;
BEGIN readln(N); for i:=1 to N do begin read(A[i]); Dp[a[i]]:=Nmax+5; end;
Dp[a[n]]:=0; V[a[n]]:=0; for i:=N-1 downto 1 do begin if(Dp[a[i]]>Dp[a[i+1]]+1) then begin Dp[a[i]]:=Dp[a[i+1]]+1; V[a[i]]:=a[i+1]; end; end;
write(a[1],' '); i:=V[a[1]]; while(i<>0) do begin write(i,' '); i:=V[i]; end; END. #include<iostream> int main() { using namespace std; unsigned long long n,id[10000],x; int m[100],y,i,j; cin>>n; for(i=0;i<n;i++) cin>>id[i]>>m[i]; for(i=0;i<n;i++) { for(j=i;j<n;j++) { if(m[i]<m[i+1]) { x=id[i]; id[i]=id[i+1]; id[i+1]=x; y=m[i]; m[i]=m[i+1]; m[i+1]=y; } } }
for(i=0;i<n;i++) cout<<id[i]<<" "<<m[i]<<"\n"; return 0; } i try use hungary to get some line use more student,than try the no use student,but wa on #12,pls help me! [delete] Edited by author 23.06.2015 16:37 Edited by author 23.06.2015 16:37 var n,m,i,j:integer; a:array[1..1000]of integer; b:array[1..1000]of real; begin read(n,m); for i:=1 to m do readln(a[i]); for j:=1 to n do begin for i:=1 to m do begin if j=a[i] then b[j]:=b[j]+1; end; end; for i:=1 to n do begin b[i]:=(b[i]/m)*100; writeln(b[i]:0:2,'%'); end; end. read(n,m); ---> readln(n,m); try this |
|
|