Submission #00061
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main{ static FastScanner s= new FastScanner(System.in); void solve(){ int n=gInt(); var a= new long [n+1]; for ( int i=1;i<=n;++i) a[i]=gInt()*2; Arrays.parallelPrefix(a,Long::sum); for ( int i:rep(gInt())) { int v=~Arrays.binarySearch(a,gInt()*2-1); System.out.println(v==n+1? "Broadcasting accident" :v); } } public static void main(String[] $){ new Main().solve(); } int gInt(){ return s.nextInt(); } long gLong(){ return s.nextLong(); } double gDouble(){ return Double.parseDouble(s.next()); } SupplyingIterator<Integer> ints( int n){ return new SupplyingIterator<>(n, this ::gInt); } SupplyingIterator<Long> longs( int n){ return new SupplyingIterator<>(n, this ::gLong); } SupplyingIterator<Double> doubles( int n){ return new SupplyingIterator<>(n, this ::gDouble); } SupplyingIterator<String> strs( int n){ return new SupplyingIterator<>(n,s::next); } Range rep( int i){ return Range.rep(i); } Range rep( int f, int t, int d){ return Range.rep(f,t,d); } Range rep( int f, int t){ return rep(f,t,1); } Range rrep( int f, int t){ return rep(t,f,-1); } IntStream INTS( int n){ return IntStream.generate( this ::gInt).limit(n); } Stream<String> STRS( int n){ return Stream.generate(s::next).limit(n); } } class FastScanner{ private final BufferedInputStream in; private static final int bufSize=1<<16; private final byte buf[]= new byte[bufSize]; private int i=bufSize,k=bufSize; private final StringBuilder str= new StringBuilder(); FastScanner(InputStream in){ this .in= new BufferedInputStream(in,bufSize); } int nextInt(){ return ( int )nextLong(); } long nextLong(){ int c; long x=0; boolean sign= true ; while ((c=nextChar())<=32) ; if (c== '-' ){ sign= false ; c=nextChar(); } if (c== '+' ){ c=nextChar(); } while (c>= '0' ){ x=x*10+(c- '0' ); c=nextChar(); } return sign?x:-x; } private int nextChar(){ if (i==k){ try { k=in.read(buf,i=0,bufSize); } catch (IOException e){ System. exit (-1); } } return i>=k?-1:buf[i++]; } String next(){ int c; str.setLength(0); while ((c=nextChar())<=32&&c!=-1) ; if (c==-1) return null; while (c>32){ str.append(( char )c); c=nextChar(); } return str.toString(); } String nextLine(){ int c; str.setLength(0); while ((c=nextChar())<=32&&c!=-1) ; if (c==-1) return null; while (c!= '\n' ){ str.append(( char )c); c=nextChar(); } return str.toString(); } } class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{ private int remain; Supplier<T> supplier; SupplyingIterator( int t,Supplier<T> supplier){ this .remain=t; this .supplier=supplier; } @Override public Iterator<T> iterator(){ return this ; } @Override public boolean hasNext(){ return remain>0; } @Override public T next(){ --remain; return supplier.get(); } } class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{ public final int from,to,d; private int cur; Range( int from, int to, int d){ this .from=from; this .cur=from-d; this .to=to; this .d=d; } Range( int n){ this (0,n-1,1); } @Override public Iterator<Integer> iterator(){ return this ; } @Override public boolean hasNext(){ return cur+d==to||(cur!=to&&(cur<to==cur+d<to)); } @Override public int nextInt(){ return cur+=d; } protected final int CHARACTERISTICS=Spliterator.SIZED|Spliterator.DISTINCT|Spliterator.IMMUTABLE|Spliterator.NONNULL; @Override public Spliterator.OfInt spliterator(){ return Spliterators.spliterator( this ,(to-from)/d+1,CHARACTERISTICS); } IntStream stream(){ return d==1?IntStream.rangeClosed(from,to):java.util.stream.StreamSupport.intStream( this .spliterator(), false ); } static Range rep( int i){ return new Range(i); } static Range rep( int f, int t, int d){ return new Range(f,t,d); } static Range rep( int f, int t){ return rep(f,t,1); } static Range rrep( int f, int t){ return rep(t,f,-1); } } |
ステータス
項目 | データ |
---|---|
問題 | 0004 - 魔女っ娘ヒナくるん -Magic.02 |
ユーザー名 | fal_rnd |
投稿日時 | 2018-08-22 11:14:49 |
言語 | Java |
状態 | Accepted |
得点 | 10 |
ソースコード長 | 4275 Byte |
最大実行時間 | 649 ms |
最大メモリ使用量 | 47912 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | Burned Out | 2 / 2 | Magic0[1-9], Magic1[0-9], Magic2[0-9], Magic30 |
2 | Missfortune | 8 / 8 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # | |
---|---|---|---|---|---|
Magic01 | AC | 116 ms | 14300 KB |
1
|
2
|
Magic02 | AC | 116 ms | 14764 KB |
1
|
2
|
Magic03 | AC | 116 ms | 14748 KB |
1
|
2
|
Magic04 | AC | 124 ms | 15348 KB |
1
|
2
|
Magic05 | AC | 125 ms | 17024 KB |
1
|
2
|
Magic06 | AC | 127 ms | 15772 KB |
1
|
2
|
Magic07 | AC | 133 ms | 15500 KB |
1
|
2
|
Magic08 | AC | 128 ms | 15024 KB |
1
|
2
|
Magic09 | AC | 120 ms | 15528 KB |
1
|
2
|
Magic10 | AC | 123 ms | 15756 KB |
1
|
2
|
Magic11 | AC | 130 ms | 15404 KB |
1
|
2
|
Magic12 | AC | 126 ms | 15712 KB |
1
|
2
|
Magic13 | AC | 124 ms | 15492 KB |
1
|
2
|
Magic14 | AC | 121 ms | 15572 KB |
1
|
2
|
Magic15 | AC | 131 ms | 15160 KB |
1
|
2
|
Magic16 | AC | 122 ms | 15436 KB |
1
|
2
|
Magic17 | AC | 138 ms | 15000 KB |
1
|
2
|
Magic18 | AC | 128 ms | 15164 KB |
1
|
2
|
Magic19 | AC | 133 ms | 17464 KB |
1
|
2
|
Magic20 | AC | 123 ms | 15212 KB |
1
|
2
|
Magic21 | AC | 128 ms | 15864 KB |
1
|
2
|
Magic22 | AC | 131 ms | 15772 KB |
1
|
2
|
Magic23 | AC | 124 ms | 15336 KB |
1
|
2
|
Magic24 | AC | 127 ms | 15416 KB |
1
|
2
|
Magic25 | AC | 127 ms | 15620 KB |
1
|
2
|
Magic26 | AC | 121 ms | 15768 KB |
1
|
2
|
Magic27 | AC | 123 ms | 15544 KB |
1
|
2
|
Magic28 | AC | 126 ms | 17596 KB |
1
|
2
|
Magic29 | AC | 124 ms | 15628 KB |
1
|
2
|
Magic30 | AC | 127 ms | 15704 KB |
1
|
2
|
Magic31 | AC | 595 ms | 29464 KB |
2
|
|
Magic32 | AC | 628 ms | 32240 KB |
2
|
|
Magic33 | AC | 582 ms | 31056 KB |
2
|
|
Magic34 | AC | 602 ms | 31744 KB |
2
|
|
Magic35 | AC | 610 ms | 32136 KB |
2
|
|
Magic36 | AC | 592 ms | 32936 KB |
2
|
|
Magic37 | AC | 613 ms | 33532 KB |
2
|
|
Magic38 | AC | 604 ms | 34392 KB |
2
|
|
Magic39 | AC | 589 ms | 34996 KB |
2
|
|
Magic40 | AC | 589 ms | 35640 KB |
2
|
|
Magic41 | AC | 598 ms | 36160 KB |
2
|
|
Magic42 | AC | 621 ms | 37136 KB |
2
|
|
Magic43 | AC | 587 ms | 37772 KB |
2
|
|
Magic44 | AC | 610 ms | 38372 KB |
2
|
|
Magic45 | AC | 587 ms | 39164 KB |
2
|
|
Magic46 | AC | 576 ms | 39868 KB |
2
|
|
Magic47 | AC | 608 ms | 40584 KB |
2
|
|
Magic48 | AC | 597 ms | 43616 KB |
2
|
|
Magic49 | AC | 649 ms | 44576 KB |
2
|
|
Magic50 | AC | 603 ms | 47912 KB |
2
|