Please sign in first.
提出 #59603941
ソースコード 拡げる
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
long long n;
int m;
long long sum;
int a[1000000],b[1000000];
int main(){
scanf("%lld %d",&n,&m);
for (int i=0;i<m;i++){
scanf("%d",&a[i]);
if(i==0){
if(a[i]!=1){
printf("-1\n");
return 0;
}
}
}
for (int i=0;i<m;i++){
scanf("%d",&b[i]);
if(i==m-1){
if(n-a[i]+1<b[i]){
printf("-1\n");
return 0;
}
}
}
for (int i=0;i<m-1;i++){
if(a[i+1]-a[i]>b[i]){
printf("-1\n");
return 0;
}
sum+=(2*b[i]-1-(a[i+1]-a[i]-1))*(a[i+1]-a[i]-1)/2;
b[i+1]+=(b[i]-(a[i+1]-a[i]));
}
sum+=b[m-1];
if(b[m-1]!=n-a[m-1]+1){
printf("-1\n");
return 0;
}
printf("%d\n",sum-1);
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - Sowing Stones |
| ユーザ | yan_cheng |
| 言語 | C++ 20 (gcc 12.2) |
| 得点 | 0 |
| コード長 | 732 Byte |
| 結果 | WA |
| 実行時間 | 1 ms |
| メモリ | 3880 KiB |
コンパイルエラー
Main.cpp: In function ‘int main()’:
Main.cpp:41:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
41 | printf("%d\n",sum-1);
| ~^ ~~~~~
| | |
| int long long int
| %lld
Main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%lld %d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
Main.cpp:20:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%d",&b[i]);
| ~~~~~^~~~~~~~~~~~
ジャッジ結果
| セット名 | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 0 / 300 | ||||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 02_hand_00.txt, 02_hand_01.txt, 02_hand_02.txt, 02_hand_03.txt, 02_hand_04.txt, 02_hand_05.txt, 02_hand_06.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3636 KiB |
| 00_sample_01.txt | AC | 1 ms | 3708 KiB |
| 01_random_00.txt | AC | 1 ms | 3632 KiB |
| 01_random_01.txt | WA | 1 ms | 3696 KiB |
| 01_random_02.txt | WA | 1 ms | 3716 KiB |
| 01_random_03.txt | WA | 1 ms | 3656 KiB |
| 01_random_04.txt | AC | 1 ms | 3636 KiB |
| 01_random_05.txt | AC | 1 ms | 3696 KiB |
| 01_random_06.txt | WA | 1 ms | 3648 KiB |
| 01_random_07.txt | WA | 1 ms | 3692 KiB |
| 01_random_08.txt | AC | 1 ms | 3764 KiB |
| 01_random_09.txt | AC | 1 ms | 3508 KiB |
| 01_random_10.txt | WA | 1 ms | 3692 KiB |
| 01_random_11.txt | WA | 1 ms | 3516 KiB |
| 01_random_12.txt | WA | 1 ms | 3684 KiB |
| 01_random_13.txt | AC | 1 ms | 3692 KiB |
| 01_random_14.txt | WA | 1 ms | 3644 KiB |
| 01_random_15.txt | AC | 1 ms | 3692 KiB |
| 01_random_16.txt | AC | 1 ms | 3692 KiB |
| 01_random_17.txt | AC | 1 ms | 3700 KiB |
| 01_random_18.txt | AC | 1 ms | 3512 KiB |
| 01_random_19.txt | AC | 1 ms | 3636 KiB |
| 01_random_20.txt | WA | 1 ms | 3512 KiB |
| 01_random_21.txt | AC | 1 ms | 3640 KiB |
| 01_random_22.txt | WA | 1 ms | 3880 KiB |
| 01_random_23.txt | AC | 1 ms | 3648 KiB |
| 01_random_24.txt | WA | 1 ms | 3632 KiB |
| 01_random_25.txt | AC | 1 ms | 3572 KiB |
| 01_random_26.txt | WA | 1 ms | 3684 KiB |
| 01_random_27.txt | AC | 1 ms | 3632 KiB |
| 01_random_28.txt | WA | 1 ms | 3688 KiB |
| 01_random_29.txt | AC | 1 ms | 3692 KiB |
| 01_random_30.txt | WA | 1 ms | 3692 KiB |
| 01_random_31.txt | AC | 1 ms | 3592 KiB |
| 01_random_32.txt | WA | 1 ms | 3712 KiB |
| 01_random_33.txt | AC | 1 ms | 3656 KiB |
| 02_hand_00.txt | AC | 1 ms | 3708 KiB |
| 02_hand_01.txt | AC | 1 ms | 3700 KiB |
| 02_hand_02.txt | WA | 1 ms | 3708 KiB |
| 02_hand_03.txt | WA | 1 ms | 3660 KiB |
| 02_hand_04.txt | WA | 1 ms | 3632 KiB |
| 02_hand_05.txt | AC | 1 ms | 3696 KiB |
| 02_hand_06.txt | WA | 1 ms | 3664 KiB |