提出 #45222586
ソースコード 拡げる
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
#define Ed for(int i=h[x];~i;i=ne[i])
#define Ls(i,l,r) for(int i=l;i<r;++i)
#define Rs(i,l,r) for(int i=l;i>r;--i)
#define Le(i,l,r) for(int i=l;i<=r;++i)
#define Re(i,l,r) for(int i=l;i>=r;--i)
#define L(i,l) for(int i=0;i<l;++i)
#define E(i,l) for(int i=1;i<=l;++i)
#define W(t) while(t--)
#define Wh while
typedef long long ll;
const int N=210;
int n,cur;
ll x[N],l[N],tmp[N*N*2],pos[N];
bool check(ll xx){
E(i, n)pos[i]=abs(x[i]-xx);
sort(pos+1,pos+1+n);
E(i, n)
if(pos[i]>l[i])return 0;
return 1;
}
int main(){
#ifndef ONLINE_JUDGE
freopen("1.in","r",stdin);
#endif
scanf("%d",&n);
E(i, n)scanf("%lld",x+i);
E(i, n)scanf("%lld",l+i);
E(i, n)
E(j, n)tmp[++cur]=x[i]+l[j],tmp[++cur]=x[i]-l[j]-1;
sort(tmp+1,tmp+1+cur);
cur=unique(tmp+1,tmp+1+cur)-tmp-1;
ll ans=0;
E(i, cur)
ans+=check(tmp[i])*(tmp[i]-tmp[i-1]);
printf("%lld",ans);
return 0;
}
提出情報
| 提出日時 |
|
| 問題 |
F - Octopus |
| ユーザ |
WUSICHENG |
| 言語 |
C++ 23 (gcc 12.2) |
| 得点 |
575 |
| コード長 |
1055 Byte |
| 結果 |
AC |
| 実行時間 |
60 ms |
| メモリ |
2268 KiB |
コンパイルエラー
Main.cpp: In function ‘int main()’:
Main.cpp:30:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
30 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
Main.cpp:31:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
31 | E(i, n)scanf("%lld",x+i);
| ~~~~~^~~~~~~~~~~~
Main.cpp:32:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
32 | E(i, n)scanf("%lld",l+i);
| ~~~~~^~~~~~~~~~~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
575 / 575 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
example_00.txt, example_01.txt, example_02.txt |
| All |
example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| example_00.txt |
AC |
1 ms |
1640 KiB |
| example_01.txt |
AC |
1 ms |
1640 KiB |
| example_02.txt |
AC |
1 ms |
1764 KiB |
| hand_00.txt |
AC |
3 ms |
1788 KiB |
| hand_01.txt |
AC |
2 ms |
2268 KiB |
| hand_02.txt |
AC |
2 ms |
2232 KiB |
| hand_03.txt |
AC |
1 ms |
1644 KiB |
| hand_04.txt |
AC |
1 ms |
1652 KiB |
| hand_05.txt |
AC |
1 ms |
1660 KiB |
| hand_06.txt |
AC |
1 ms |
1716 KiB |
| hand_07.txt |
AC |
1 ms |
1628 KiB |
| random_00.txt |
AC |
15 ms |
2160 KiB |
| random_01.txt |
AC |
4 ms |
1740 KiB |
| random_02.txt |
AC |
29 ms |
2208 KiB |
| random_03.txt |
AC |
12 ms |
2132 KiB |
| random_04.txt |
AC |
1 ms |
1672 KiB |
| random_05.txt |
AC |
41 ms |
2236 KiB |
| random_06.txt |
AC |
24 ms |
1916 KiB |
| random_07.txt |
AC |
1 ms |
1660 KiB |
| random_08.txt |
AC |
18 ms |
2040 KiB |
| random_09.txt |
AC |
1 ms |
1628 KiB |
| random_10.txt |
AC |
3 ms |
1820 KiB |
| random_11.txt |
AC |
1 ms |
1768 KiB |
| random_12.txt |
AC |
1 ms |
1624 KiB |
| random_13.txt |
AC |
2 ms |
1772 KiB |
| random_14.txt |
AC |
2 ms |
1684 KiB |
| random_15.txt |
AC |
1 ms |
1724 KiB |
| random_16.txt |
AC |
60 ms |
2204 KiB |
| random_17.txt |
AC |
4 ms |
1680 KiB |
| random_18.txt |
AC |
2 ms |
1696 KiB |
| random_19.txt |
AC |
28 ms |
1968 KiB |
| random_20.txt |
AC |
4 ms |
1796 KiB |
| random_21.txt |
AC |
41 ms |
2140 KiB |
| random_22.txt |
AC |
1 ms |
1628 KiB |
| random_23.txt |
AC |
4 ms |
1732 KiB |
| random_24.txt |
AC |
12 ms |
1788 KiB |