# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
469335 | vincent97198 | Snowball (JOI21_ho_t2) | C++14 | 345 ms | 19380 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define int int64_t
#define double long double
using namespace std;
const double eps=1e-6;
int32_t main()
{
int n,q; cin >> n >> q;
vector<int> pos(n),d(n,1e18);
for(int i=0;i<n;++i) cin >> pos[i];
for(int i=0;i<n-1;++i) d[i]=abs(pos[i+1]-pos[i]);
vector<int> Q;
int tmp,tmp_now=0,POS_MAX=0,NEG_MIN=0;
for(int i=0;i<q;++i){
cin >> tmp;
tmp_now+=tmp;
if(tmp_now>=0 && tmp_now>POS_MAX){
if(!Q.empty() && Q.back()>=0 && tmp_now>Q.back()) Q.pop_back();
Q.emplace_back(tmp_now);
}
if(tmp_now<0 && tmp_now<NEG_MIN){
if(!Q.empty() && Q.back()<=0 && tmp_now<Q.back()) Q.pop_back();
Q.emplace_back(tmp_now);
}
POS_MAX=max(POS_MAX,tmp_now);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |