Submission #50696
ソースコード
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 | #include<bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fLL; int v[3000010]; int a[3000010]; int idx[3000010] = {}; signed main() { cin.tie(0); ios::sync_with_stdio( false ); int n; cin >> n; for ( int i = 1; i <= n; ++i ) { cin >> a[i]; idx[i] = i; } int high, low, mid; int high2, low2, mid2; int q; cin >> q; for ( int i = 0; i < q; ++i ) { cin >> v[i]; low = 0; high = n + 1; while ( high - low > 1 ) { mid = ( high + low ) / 2; if ( a[mid] > v[i] ) high = mid; else low = mid; } low2 = 0; high2 = n + 1; while ( high2 - low2 > 1 ) { mid2 = ( high2 + low2 ) / 2; if ( a[mid2] >= v[i] ) high2 = mid2; else low2 = mid2; } cout << idx[low] - idx[low2] << '\n' ; } return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0948 - Number-Collection |
ユーザー名 | もけ |
投稿日時 | 2019-06-19 17:32:56 |
言語 | C++ |
状態 | Accepted |
得点 | 10 |
ソースコード長 | 906 Byte |
最大実行時間 | 335 ms |
最大メモリ使用量 | 32272 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | a_NQ-small | 1 / 1 | *E?? |
2 | b_a-small-positive | 1 / 1 | *?E? |
3 | c_a-unique | 3 / 3 | *??E |
4 | d_ALL | 5 / 5 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # | |||
---|---|---|---|---|---|---|---|
input-sample1EEE | AC | 28 ms | 4700 KB |
1
|
2
|
3
|
4
|
input-sample2E__ | AC | 19 ms | 4788 KB |
1
|
4
|
||
input01EEE | AC | 15 ms | 4740 KB |
1
|
2
|
3
|
4
|
input02EEE | AC | 16 ms | 4688 KB |
1
|
2
|
3
|
4
|
input03E__ | AC | 23 ms | 4640 KB |
1
|
4
|
||
input04E__ | AC | 22 ms | 4712 KB |
1
|
4
|
||
input05E__ | AC | 20 ms | 4652 KB |
1
|
4
|
||
input06_E_ | AC | 129 ms | 13944 KB |
2
|
4
|
||
input07_E_ | AC | 164 ms | 18888 KB |
2
|
4
|
||
input08_E_ | AC | 205 ms | 28312 KB |
2
|
4
|
||
input09__E | AC | 335 ms | 30960 KB |
3
|
4
|
||
input10__E | AC | 159 ms | 17216 KB |
3
|
4
|
||
input11__E | AC | 226 ms | 29588 KB |
3
|
4
|
||
input12___ | AC | 113 ms | 13156 KB |
4
|
|||
input13___ | AC | 128 ms | 16712 KB |
4
|
|||
input14___ | AC | 92 ms | 20760 KB |
4
|
|||
input15___ | AC | 245 ms | 31468 KB |
4
|
|||
input16___ | AC | 255 ms | 31808 KB |
4
|
|||
input17___ | AC | 266 ms | 32272 KB |
4
|
|||
input18 | AC | 40 ms | 12004 KB |
4
|