# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
757478 | 2023-06-13T08:48:41 Z | Nika533 | Snowball (JOI21_ho_t2) | C++14 | 2 ms | 632 KB |
#pragma GCC diagnostic warning "-std=c++11" #include <bits/stdc++.h> #define int long long #define pb push_back #define f first #define s second #define MOD 1000000007 #define flush fflush(stdout) #define all(x) (x).begin(),(x).end() using namespace std; int n,m,T,k; string s; void test_case() { cin>>n>>m; int arr[n+1]; map<int,int> mymap; for (int i=1; i<=n; i++) { cin>>arr[i]; } int b[m+1]; b[0]=0; int mx=0; int mn=0; set<int> myset; for (int i=1; i<=m; i++) { cin>>b[i]; b[i]+=b[i-1]; //cout<<i<<" "<<b[i]<<" B"<<endl; if (b[i]>mx) { mx=b[i]; int num=b[i]-mn; myset.insert(num); mymap[num]=mn; //cout<<"B1 "<<num<<" "<<mn<<endl; } if (b[i]<mn) { mn=b[i]; int num=mx-b[i]; myset.insert(num); mymap[num]=mx; //cout<<"B2 "<<num<<" "<<mx<<endl; } } vector<int> ans(n+1,0); for (int i=1; i<n; i++) { // i --- i+1 int dist=arr[i+1]-arr[i]; set<int> :: iterator it=myset.lower_bound(dist); if (it==myset.end()) { ans[i]+=mx; ans[i+1]+=-mn; continue; } int num=mymap[*it]; //cout<<"AAA"<<i<<" "<<i+1<<" "<<*it<<" "<<num<<endl; if (num>0) { ans[i]+=num; ans[i+1]+=dist-num; //cout<<i<<" "<<num<<" "<<dist-num<<endl; } else { num=-num; ans[i+1]+=num; ans[i]+=dist-num; //cout<<i<<" "<<dist-num<<" "<<num<<endl; } } ans[1]+=-mn; ans[n]+=mx; for (int i=1; i<=n; i++) { cout<<ans[i]<<" "; } cout<<endl; } main () { ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0); T=1; while (T--) { test_case(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 468 KB | Output is correct |
2 | Correct | 1 ms | 456 KB | Output is correct |
3 | Correct | 2 ms | 468 KB | Output is correct |
4 | Correct | 2 ms | 632 KB | Output is correct |
5 | Correct | 2 ms | 596 KB | Output is correct |
6 | Correct | 2 ms | 596 KB | Output is correct |
7 | Incorrect | 2 ms | 596 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 468 KB | Output is correct |
2 | Correct | 1 ms | 456 KB | Output is correct |
3 | Correct | 2 ms | 468 KB | Output is correct |
4 | Correct | 2 ms | 632 KB | Output is correct |
5 | Correct | 2 ms | 596 KB | Output is correct |
6 | Correct | 2 ms | 596 KB | Output is correct |
7 | Incorrect | 2 ms | 596 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |