Submission #59592695
Source Code Expand
Copy
#include<bits/stdc++.h>using namespace std;const int N = 2e5+7;typedef long long ll;struct cell{int x,a;bool operator<(const cell &t) const{return x < t.x;}}c[N];int n,m;ll r,res;int main(){scanf("%d%d",&n,&m);for(int i = 1;i <= m;i++) scanf("%d",&c[i].x);for(int i = 1;i <= m;i++) scanf("%d",&c[i].a);sort(c+1,c+m+1);if(c[1].x != 1){printf("-1\n");return 0;}for(int i = 1;i <= m;i++){if(r < c[i].x-1){
#include<bits/stdc++.h> using namespace std; const int N = 2e5+7; typedef long long ll; struct cell{ int x,a; bool operator<(const cell &t) const{return x < t.x;} }c[N]; int n,m; ll r,res; int main(){ scanf("%d%d",&n,&m); for(int i = 1;i <= m;i++) scanf("%d",&c[i].x); for(int i = 1;i <= m;i++) scanf("%d",&c[i].a); sort(c+1,c+m+1); if(c[1].x != 1){ printf("-1\n"); return 0; } for(int i = 1;i <= m;i++){ if(r < c[i].x-1){ printf("-1\n"); return 0; } res += (ll)(r+1-c[i].x+r+c[i].a-c[i].x)*c[i].a/2; r += c[i].a; } if(r == n) printf("%lld\n",res); else printf("-1\n"); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Sowing Stones |
User | juruo_114 |
Language | C++ 20 (gcc 12.2) |
Score | 300 |
Code Size | 642 Byte |
Status | AC |
Exec Time | 53 ms |
Memory | 5428 KB |
Compile Error
Main.cpp: In function ‘int main()’: Main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d%d",&n,&m); | ~~~~~^~~~~~~~~~~~~~ Main.cpp:13:40: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | for(int i = 1;i <= m;i++) scanf("%d",&c[i].x); | ~~~~~^~~~~~~~~~~~~~ Main.cpp:14:40: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | for(int i = 1;i <= m;i++) scanf("%d",&c[i].a); | ~~~~~^~~~~~~~~~~~~~
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 3664 KB |
00_sample_01.txt | AC | 1 ms | 3680 KB |
01_random_00.txt | AC | 25 ms | 4656 KB |
01_random_01.txt | AC | 26 ms | 4828 KB |
01_random_02.txt | AC | 37 ms | 5248 KB |
01_random_03.txt | AC | 26 ms | 4812 KB |
01_random_04.txt | AC | 24 ms | 4672 KB |
01_random_05.txt | AC | 28 ms | 4852 KB |
01_random_06.txt | AC | 33 ms | 5120 KB |
01_random_07.txt | AC | 30 ms | 4976 KB |
01_random_08.txt | AC | 38 ms | 5044 KB |
01_random_09.txt | AC | 42 ms | 5208 KB |
01_random_10.txt | AC | 20 ms | 4376 KB |
01_random_11.txt | AC | 26 ms | 4580 KB |
01_random_12.txt | AC | 14 ms | 4320 KB |
01_random_13.txt | AC | 16 ms | 4308 KB |
01_random_14.txt | AC | 16 ms | 4536 KB |
01_random_15.txt | AC | 21 ms | 4556 KB |
01_random_16.txt | AC | 53 ms | 5148 KB |
01_random_17.txt | AC | 37 ms | 4728 KB |
01_random_18.txt | AC | 13 ms | 3948 KB |
01_random_19.txt | AC | 29 ms | 4456 KB |
01_random_20.txt | AC | 41 ms | 5308 KB |
01_random_21.txt | AC | 41 ms | 5236 KB |
01_random_22.txt | AC | 41 ms | 5300 KB |
01_random_23.txt | AC | 41 ms | 5188 KB |
01_random_24.txt | AC | 41 ms | 5360 KB |
01_random_25.txt | AC | 41 ms | 5252 KB |
01_random_26.txt | AC | 40 ms | 5428 KB |
01_random_27.txt | AC | 40 ms | 5252 KB |
01_random_28.txt | AC | 1 ms | 3868 KB |
01_random_29.txt | AC | 1 ms | 3612 KB |
01_random_30.txt | AC | 1 ms | 3596 KB |
01_random_31.txt | AC | 1 ms | 3704 KB |
01_random_32.txt | AC | 1 ms | 3676 KB |
01_random_33.txt | AC | 1 ms | 3564 KB |
02_hand_00.txt | AC | 42 ms | 5032 KB |
02_hand_01.txt | AC | 29 ms | 4552 KB |
02_hand_02.txt | AC | 18 ms | 4412 KB |
02_hand_03.txt | AC | 13 ms | 4116 KB |
02_hand_04.txt | AC | 1 ms | 3648 KB |
02_hand_05.txt | AC | 1 ms | 3676 KB |
02_hand_06.txt | AC | 41 ms | 5204 KB |