Submission #60311659
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<cstdio>
#include<algorithm>
int n,m,a,s[200005];
int main(){
scanf("%d%d",&n,&m);
s[0]=1e9;
for(int i=1;i<=n;i++)scanf("%d",&a),s[i]=std::min(s[i-1],a);
while(m--){
scanf("%d",&a);
int l=1,r=n,ans=-1;
while(l<=r){
int mid=(l+r)>>1;
if(s[mid]<=a)ans=mid,r=mid-1;
else l=mid+1;
}
printf("%d\n",ans);
}
}
Submission Info
Submission Time |
|
Task |
C - Kaiten Sushi |
User |
zhouyihan |
Language |
C++ 17 (gcc 12.2) |
Score |
350 |
Code Size |
423 Byte |
Status |
AC |
Exec Time |
65 ms |
Memory |
2512 KB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:5:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
5 | scanf("%d%d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~
Main.cpp:7:31: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | for(int i=1;i<=n;i++)scanf("%d",&a),s[i]=std::min(s[i-1],a);
| ~~~~~^~~~~~~~~
Main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d",&a);
| ~~~~~^~~~~~~~~
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
350 / 350 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 02_random2_12.txt, 02_random2_13.txt, 02_random2_14.txt, 02_random2_15.txt, 02_random2_16.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt |
Case Name |
Status |
Exec Time |
Memory |
00_sample_00.txt |
AC |
0 ms |
1716 KB |
00_sample_01.txt |
AC |
0 ms |
1716 KB |
00_sample_02.txt |
AC |
0 ms |
1712 KB |
01_random_00.txt |
AC |
19 ms |
1956 KB |
01_random_01.txt |
AC |
9 ms |
1772 KB |
01_random_02.txt |
AC |
32 ms |
1916 KB |
01_random_03.txt |
AC |
40 ms |
2264 KB |
01_random_04.txt |
AC |
24 ms |
2168 KB |
02_random2_00.txt |
AC |
47 ms |
2512 KB |
02_random2_01.txt |
AC |
65 ms |
2484 KB |
02_random2_02.txt |
AC |
65 ms |
2364 KB |
02_random2_03.txt |
AC |
65 ms |
2488 KB |
02_random2_04.txt |
AC |
65 ms |
2372 KB |
02_random2_05.txt |
AC |
65 ms |
2392 KB |
02_random2_06.txt |
AC |
65 ms |
2412 KB |
02_random2_07.txt |
AC |
64 ms |
2496 KB |
02_random2_08.txt |
AC |
64 ms |
2348 KB |
02_random2_09.txt |
AC |
63 ms |
2480 KB |
02_random2_10.txt |
AC |
64 ms |
2500 KB |
02_random2_11.txt |
AC |
63 ms |
2508 KB |
02_random2_12.txt |
AC |
63 ms |
2496 KB |
02_random2_13.txt |
AC |
62 ms |
2492 KB |
02_random2_14.txt |
AC |
63 ms |
2416 KB |
02_random2_15.txt |
AC |
62 ms |
2396 KB |
02_random2_16.txt |
AC |
61 ms |
2368 KB |
03_handmade_00.txt |
AC |
48 ms |
2508 KB |
03_handmade_01.txt |
AC |
37 ms |
2360 KB |
03_handmade_02.txt |
AC |
23 ms |
1620 KB |
03_handmade_03.txt |
AC |
23 ms |
1624 KB |
03_handmade_04.txt |
AC |
1 ms |
1560 KB |