# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
692549 | 2023-02-01T22:52:36 Z | guagua0407 | Snowball (JOI21_ho_t2) | C++17 | 1 ms | 468 KB |
/* 燒雞 燒雞 燒雞 好想進選訓 燒雞 燒雞 */ #pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<ll,ll> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } const ll mxn=2e5+5; ll num[mxn]; ll gap[mxn]; ll ans[mxn]; int main() {_ //setIO("wayne"); ll n,q; cin>>n>>q; for(ll i=0;i<n;i++){ cin>>num[i]; } for(ll i=0;i<n-1;i++){ gap[i]=num[i+1]-num[i]; } pair<ll,ll> cur={0ll,0ll}; ll pos=0; vector<pair<ll,ll>> vec; for(ll i=0;i<q;i++){ ll x; cin>>x; pos+=x; cur.f=max(cur.f,pos*-1); cur.s=max(cur.s,pos); vec.push_back(cur); } vector<ll> sum(q); for(ll i=0;i<q;i++){ sum[i]=vec[i].f+vec[i].s; } for(ll i=0;i<n-1;i++){ ll gp=gap[i]; ll pos=upper_bound(all(sum),gp)-sum.begin()-1; if(pos==q-1){ ans[i]+=vec[pos].s; ans[i+1]+=vec[pos].f; } else{ if(vec[pos+1].f>vec[pos].f){ ans[i]+=vec[pos].s; ans[i+1]+=gp-vec[pos].s; } else{ ans[i]+=gp-vec[pos].f; ans[i+1]+=vec[pos].f; } } } ans[0]+=cur.f; ans[n-1]+=cur.s; for(ll i=0;i<n;i++){ cout<<ans[i]<<'\n'; } return 0; } //maybe its multiset not set
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 468 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Incorrect | 1 ms | 340 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 468 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Incorrect | 1 ms | 340 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |