Submission #63515998
Source Code Expand
Copy
#include <bits/stdc++.h>#include <ext/pb_ds/assoc_container.hpp>#include <ext/pb_ds/tree_policy.hpp>#define FOR(i,a,b) for (int i = (a); i < (b); i++)using namespace std;using namespace __gnu_pbds;using ll=long long;using ld=long double;using vi=vector<int>;template<class T> using oset =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;//上int main(){ios_base::sync_with_stdio(false);cin.tie(NULL);int n,m; cin >> n >> m;vector<ll> a(n);vector<ll> b(m);FOR(i,0,n) cin >> a[i];FOR(j,0,m) cin >>b[j];sort(a.begin(),a.end());sort(b.begin(),b.end());
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define FOR(i,a,b) for (int i = (a); i < (b); i++) using namespace std; using namespace __gnu_pbds; using ll=long long; using ld=long double; using vi=vector<int>; template<class T> using oset =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ; //上 int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n,m; cin >> n >> m; vector<ll> a(n); vector<ll> b(m); FOR(i,0,n) cin >> a[i]; FOR(j,0,m) cin >>b[j]; sort(a.begin(),a.end()); sort(b.begin(),b.end()); reverse(a.begin(),a.end()); reverse(b.begin(),b.end()); ll su = 0; int tot=0; FOR(i,0,n) if(a[i] >=0) su+=a[i],tot++; FOR(j,0,m){ if(j ==n) break; if(j==tot){ if(su < su+a[j]+b[j]) su =su+a[j]+b[j],tot++; else break; }else if(b[j] >0){ su +=b[j]; }else break; } cout<<su<<'\n'; }
Submission Info
Submission Time | |
---|---|
Task | C - Buy Balls |
User | zawos |
Language | C++ 20 (gcc 12.2) |
Score | 300 |
Code Size | 1049 Byte |
Status | AC |
Exec Time | 51 ms |
Memory | 6360 KB |
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, 00_sample_02.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt, 01_test_33.txt, 01_test_34.txt, 01_test_35.txt, 01_test_36.txt, 01_test_37.txt, 01_test_38.txt, 01_test_39.txt, 01_test_40.txt, 01_test_41.txt, 01_test_42.txt, 01_test_43.txt, 01_test_44.txt, 01_test_45.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 3560 KB |
00_sample_01.txt | AC | 1 ms | 3528 KB |
00_sample_02.txt | AC | 1 ms | 3424 KB |
01_test_00.txt | AC | 1 ms | 3492 KB |
01_test_01.txt | AC | 1 ms | 3424 KB |
01_test_02.txt | AC | 1 ms | 3556 KB |
01_test_03.txt | AC | 25 ms | 4660 KB |
01_test_04.txt | AC | 17 ms | 4112 KB |
01_test_05.txt | AC | 16 ms | 4072 KB |
01_test_06.txt | AC | 50 ms | 6192 KB |
01_test_07.txt | AC | 50 ms | 6264 KB |
01_test_08.txt | AC | 50 ms | 6360 KB |
01_test_09.txt | AC | 51 ms | 6264 KB |
01_test_10.txt | AC | 50 ms | 6352 KB |
01_test_11.txt | AC | 50 ms | 6256 KB |
01_test_12.txt | AC | 50 ms | 6240 KB |
01_test_13.txt | AC | 51 ms | 6188 KB |
01_test_14.txt | AC | 50 ms | 6200 KB |
01_test_15.txt | AC | 44 ms | 5700 KB |
01_test_16.txt | AC | 49 ms | 6228 KB |
01_test_17.txt | AC | 42 ms | 5724 KB |
01_test_18.txt | AC | 50 ms | 6188 KB |
01_test_19.txt | AC | 45 ms | 5936 KB |
01_test_20.txt | AC | 50 ms | 6360 KB |
01_test_21.txt | AC | 42 ms | 5692 KB |
01_test_22.txt | AC | 49 ms | 6256 KB |
01_test_23.txt | AC | 40 ms | 5736 KB |
01_test_24.txt | AC | 50 ms | 6192 KB |
01_test_25.txt | AC | 39 ms | 5320 KB |
01_test_26.txt | AC | 50 ms | 6188 KB |
01_test_27.txt | AC | 42 ms | 5828 KB |
01_test_28.txt | AC | 48 ms | 6352 KB |
01_test_29.txt | AC | 41 ms | 5680 KB |
01_test_30.txt | AC | 49 ms | 6240 KB |
01_test_31.txt | AC | 35 ms | 5488 KB |
01_test_32.txt | AC | 49 ms | 6188 KB |
01_test_33.txt | AC | 37 ms | 5692 KB |
01_test_34.txt | AC | 46 ms | 6236 KB |
01_test_35.txt | AC | 39 ms | 5708 KB |
01_test_36.txt | AC | 47 ms | 6276 KB |
01_test_37.txt | AC | 32 ms | 5164 KB |
01_test_38.txt | AC | 49 ms | 6240 KB |
01_test_39.txt | AC | 36 ms | 5428 KB |
01_test_40.txt | AC | 47 ms | 6208 KB |
01_test_41.txt | AC | 35 ms | 5320 KB |
01_test_42.txt | AC | 49 ms | 6172 KB |
01_test_43.txt | AC | 1 ms | 3436 KB |
01_test_44.txt | AC | 25 ms | 4640 KB |
01_test_45.txt | AC | 26 ms | 4600 KB |