Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [0,0,0,0] -> 0
- [12,312,33,12] -> 4
- [1,2,3,4,5,6,7] -> 4
- [22,33,1,2,4] -> 3
- [1000,2,2,2] -> 2
- [23,42,12,92,39,46,23,56,31,12,43,23,54,23,56,73,35,73,42,12,10,15,35,23,12,42] -> 20
- +/⊢≥⍋∘⍒
- f←+/⊢≥⍋∘⍒
- f¨(4⍴0)(12 312 33 12)(⍳7)(22 33 1 2 4)(1000 2 2 2)(23 42 12 92 39 46 23 56 31 12 43 23 54 23 56 73 35 73 42 12 10 15 35 23 12 42)
- 0 4 4 3 2 20
- tf<l-QUTT1
- i=0
- for z in sorted(input())[::-1]:i+=z>i
- print i
- l~{~}${W):W>},,
- [:+/i.@#<:~
- f=:[:+/i.@:#<:~
- f 0,0,0,0
- 0
- f 12,312,33,12
- 4
- f 1,2,3,4,5,6,7
- 4
- f 22,33,1,2,4
- 3
- f 1000,2,2,2
- 2
- f 23,42,12,92,39,46,23,56,31,12,43,23,54,23,56,73,35,73,42,12,10,15,35,23,12,42
- 20
- LengthWhile[i=0;SortBy[#,-#&],#>i++&]&
- In: LengthWhile[i=0;SortBy[#,-#&],#>i++&]&@{1,2,3,4,5,6,7}
- Out: 4
- SELECT COUNT(R)FROM(SELECT ROW_NUMBER()OVER(ORDER BY V DESC)R,V FROM I)A WHERE R<=V
- l~:I,),W%{_If>:!:+>}$0=
- [23 42 12 92 39 46 23 56 31 12 43 23 54 23 56 73 35 73 42 12 10 15 35 23 12 42]
- [0 0 0 0]
- [12 312 33 12]
- [1 2 3 4 5 6 7]
- [22 33 1 2 4]
- [1000 2 2 2]
- [23 42 12 92 39 46 23 56 31 12 43 23 54 23 56 73 35 73 42 12 10 15 35 23 12 42]]
- {:I,),W%{_If>:!:+>}$0=N}/
- l~:I,),W%{_If>:!:+>}$0=
- l~:I "Read input, evaluate, store in I.";
- , "Get length of input N.";
- ),W% "Create range from 0 to N, reverse.";
- { }$ "Sort stably.";
- _I "Duplicate candidate h, push input list.";
- f> "Map each number to 1 if it's less or 0 otherwise.";
- :! "Invert all results.";
- :+ "Sum them up.";
- > "Check if the sum is less than the candidate h.";
- 0= "Pick the first element.";
- #!perl -pa
- $_=grep$_>$i++,sort{$b<=>$a}@F
- perl hidx.pl <<<'1 2 3 4 5 6 7'
- lambda x:sum(a>b for a,b in zip(sorted(x)[::-1],range(len(x))))
- f=->a,n=0{a.count{|x|x>n}<n+1?n:f[a,n+1]}
- f=->a{a.size.downto(0).find{|x|a.count{|y|y>=x}>=x}}
- sort -nr|nl -s>|bc|grep -c 0
- $ for i in {23,42,12,92,39,46,23,56,31,12,43,23,54,23,56,73,35,73,42,12,10,15,35,23,12,42}; do echo $i; done | ./atleasth.sh
- 20
- $ for i in {1,2,3,4,5,6,7}; do echo $i; done | ./atleasth.sh
- 4
- $
- s=sort(i);sum(s>=length(s):1)
- > i=c(23,42,12,92,39,46,23,56,31,12,43,23,54,23,56,73,35,73,42,12,10,15,35,23,12,42)
- > s=sort(i);length(s[s>=length(s):1])
- [1] 20
- > i=c(0,0,0,0)
- > s=sort(i);length(s[s>=length(s):1])
- [1] 0
- f s=[x-1|x<-[1..],x>sum[1|r<-s,r>=x]]!!0
- [0, 0, 0, 0] 0
- [12, 312, 33, 12] 4
- [1, 2, 3, 4, 5, 6, 7] 4
- [22, 33, 1, 2, 4] 3
- [1000, 2, 2, 2] 2
- [23, 42, 12, 92, 39, 46, 23, 56, 31, 12, 43, 23, 54, 23, 56, 73, 35, 73, 42, 12, 10, 15, 35, 23, 12, 42] 20
- NỤỤ<’S
- N Negate (so that repeated elements won't mess up the second grade down)
- Ụ Grade down
- Ụ Twice.
- <’ Predicate, check for each element if the new one (after grading) is lower than original array (minus 1 on each element)
- S Sum
- q~:Q,),{Q{1$>},,>!},W=
- [23 42 12 92 39 46 23 56 31 12 43 23 54 23 56 73 35 73 42 12 10 15 35 23 12 42]
- 20
- $-1%0{1$>+}/
- Input L1:1:While Ans≤sum(Ans≥L1:Ans+1:End:Ans
- DC 5D 00 3E 31 3E D1 72 6D B6 72 6C 5D 00 3E 72 70 31 3E D4 3E 72
- #include <iostream>
- #include <list>
- using namespace std;int main(int c,char** v){list<int>n(--c);int h=c;for(int&m:n)m=atoi(*(v+(h--)));n.sort();for(auto r=n.rbegin();r!=n.rend()&&*r++>++h;);cout<<(h==c?h:--h)<<endl;}
- 0SJC{Sd@>+1}/S
- 0 Push the number 0 (the counter)
- SJC Swap to array, sort and reverse
- {Sd@>+1}/ For each item in the array, add 1 to counter if counter is less than item
- S Swap counter to top of stack
- [:+/#<::~
- ([:+/#<::~) 1 2 3 4 5 6 7
- 4
- */ (([:+/#<::~) = ([:+/i.@#<:~))"1 ?100 100$100
- 1
- 1#xk#yaïí'1ø ~n-1$
- 1+)x(%:1,%1ex+y1-?^#y#x
- 1#xk#yaïí'1ø
- 1+)x(%:1,%1ex+y1-?^#y#x
- Command | Stack
- --- | a, b
- % | a/b
- : | a/b, a/b
- 1 | a/b, a/b, 1
- , | a/b, (a/b)%1
- e | (a/b) == ((a/b)%1)
- ~n-1$
- FirstCase[Range[Length@#,0,-1],h_/;Count[#,k_/;k>=h]>=h]&
- FirstCase[Range[Length@#,0,-1],h_/;Count[#,k_/;k>=h]>=h]&@{1,2,3,4,5,6,7}
- FirstCase[Range[Length@#,0,-1],h_/;Count[#,k_/;k>=h]>=h]& /@ {
- {0, 0, 0, 0},
- {12, 312, 33, 12},
- {1, 2, 3, 4, 5, 6, 7},
- {22, 33, 1, 2, 4},
- {1000, 2, 2, 2},
- {23, 42, 12, 92, 39, 46, 23, 56, 31, 12, 43, 23, 54, 23, 56, 73, 35,
- 73, 42, 12, 10, 15, 35, 23, 12, 42}
- }
- def h(a:Int*)=Range(a.size,-1,-1).find(b=>a.count(b<=)>=b).get
- long f(java.util.ArrayList<Long>l){for(int i=0;;){long x=i++;l.removeIf(j->j<x);if(l.size()<x)return x-1;}}
- long f(java.util.ArrayList<Long> l) {
- for(int i = 0;;) {
- long x = i;
- i++;
- l.removeIf(j -> j<x);
- if(l.size() < x)
- return x-1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement