Submission #757491

#TimeUsernameProblemLanguageResultExecution timeMemory
757491Nika533Snowball (JOI21_ho_t2)C++17
100 / 100
426 ms34124 KiB
#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); if (mn==0) { mymap[num]=-1e18; } else { mymap[num]=mn; } //cout<<"B1 "<<num<<" "<<mn<<endl; } if (b[i]<mn) { mn=b[i]; int num=mx-b[i]; myset.insert(num); if (mx==0) { mymap[num]=1e18; } else { 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) { if (num==1e18) { num=0; } ans[i]+=num; ans[i+1]+=dist-num; //cout<<i<<" "<<num<<" "<<dist-num<<endl; } else { if (num==-1e18) { num=0; } 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 (stderr)

Main.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
    1 | #pragma GCC diagnostic warning "-std=c++11"
      |                                ^~~~~~~~~~~~
Main.cpp:91:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   91 | main () {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...