Submission #66122726


Source Code Expand

#include<bits/stdc++.h>
#define inl inline
#define reg register
#define int long long
#define lll __int128
#define fst ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,x,y) for(reg int i=x;i<=(y);++i) 
#define per(i,x,y) for(reg int i=x;i>=(y);--i)
#define rpr(i,x,y,z) for(reg int i=x;i<=(y);i+=z)
#define epe(i,x,y,z) for(reg int i=x;i>=(y);i-=z)
#define repe(i,x,y) for(i=x;i<=(y);++i) 
#define endl '\n'
#define INF 1e18
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front 
#define fi first
#define se second
#define lcm(x,y) x/__gcd(x,y)*y
#define ull unsigned long long
#define prr make_pair
#define pii pair<int,int> 
#define gt(s) getline(cin,s)
#define at(x,y) for(reg auto x:y)
#define ff fflush(stdout)
#define mt(x,y) memset(x,y,sizeof(x))
#define idg isdigit
#define fp(s) string ssss=s;freopen((ssss+".in").c_str(),"r",stdin);freopen((ssss+\
".out").c_str(),"w",stdout);
#define sstr stringstream 
#define all(x) x.begin(),x.end()
#define mcy(a,b) memcpy(a,b,sizeof(b))
#define ui unsigned
#define si signed
#define eb emplace_back
#define pff(x) (x)*(x)
#define eush emplace
using namespace std;
const int N=2e5+5;
int a[N],lst[N],nxt[N],c[N];
stack<int>st;
signed main(){
	fst;
	reg int n;
	cin>>n;
	rep(i,1,n) cin>>a[i];
	a[0]=a[n+1]=INF;
	rep(i,1,n+1){
		while(!st.empty()&&a[st.top()]<=a[i]){
			nxt[st.top()]=i-1;
			st.pop();
		}
		st.push(i);
	}
	st.pop();
	per(i,n,0){
		while(!st.empty()&&a[st.top()]<a[i]){
			lst[st.top()]=i+1;
			st.pop();
		}
		st.push(i);
	}
	rep(i,1,n){
		c[1]+=a[i];
		c[min(nxt[i]-i,i-lst[i])+2]-=a[i];
		c[max(nxt[i]-i,i-lst[i])+2]-=a[i];
		c[nxt[i]-lst[i]+3]+=a[i];
	}
	rep(i,1,n) c[i]+=c[i-1];
	rep(i,1,n) c[i]+=c[i-1];
	rep(i,1,n) cout<<c[i]<<endl;
	return 0;
}

Submission Info

Submission Time
Task F - Sums of Sliding Window Maximum
User Morishima_
Language C++ 20 (gcc 12.2)
Score 550
Code Size 1834 Byte
Status AC
Exec Time 27 ms
Memory 11396 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:45:17: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   45 |         reg int n;
      |                 ^
Main.cpp:46:14: warning: address requested for ‘n’, which is declared ‘register’ [-Wextra]
   46 |         cin>>n;
      |              ^
Main.cpp:47:13: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   47 |         rep(i,1,n) cin>>a[i];
      |             ^
Main.cpp:7:32: note: in definition of macro ‘rep’
    7 | #define rep(i,x,y) for(reg int i=x;i<=(y);++i)
      |                                ^
Main.cpp:49:13: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   49 |         rep(i,1,n+1){
      |             ^
Main.cpp:7:32: note: in definition of macro ‘rep’
    7 | #define rep(i,x,y) for(reg int i=x;i<=(y);++i)
      |                                ^
Main.cpp:54:24: warning: address requested for ‘i’, which is declared ‘register’ [-Wextra]
   54 |                 st.push(i);
      |                 ~~~~~~~^~~
Main.cpp:57:13: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   57 |         per(i,n,0){
      |             ^
Main.cpp:8:32: note: in definition of macro ‘per’
    8 | #define per(i,x,y) for(reg int i=x;i>=(y);--i)
      |                                ^
Main.cpp:62:24: warning: address requested for ‘i’, which is declared ‘register’ [-Wextra]
   62 |                 st.push(i);
      |                 ~~~~~~~^~~
Main.cpp:64:13: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   64 |         rep(i,1,n){
      |             ^
Main.cpp:7:32: note: in definition of macro ‘rep’
    7 | #define rep(i,x,y) for(reg int i=x;i<=(y);++i)
      |                                ^
Main.cpp:70:13: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   70 |         rep(i,1,n) c[i]+=c[i-1];
      |             ^
Main.cpp:7:32: note: in definition of macro ‘rep’
    7 | #define rep(i,x,y) for(reg int i=x;i<=(y);++i)
      |                                ^
Main.cpp:71:13: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   71 |         rep(i,1,n) c[i]+=c[i-1];
      |             ^
Main.cpp:7:32: note: in definition of macro ‘rep’
    7 | #define rep(i,x,y) for(reg int i=x;i<=(y);++i)
      |                                ^
Main.cpp:72:13: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
   72 |         rep(i,1,n) cout<<c[i]<<endl;
      |             ^
Main.cpp:7:32: note: in definition of macro ‘rep’
    7 | #define rep(i,x,y) for(reg int i=x;i<=(y);++i)
      |                                ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 550 / 550
Status
AC × 3
AC × 37
Set Name Test Cases
Sample 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt
All 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-small-01.txt, 01-small-02.txt, 01-small-03.txt, 01-small-04.txt, 01-small-05.txt, 01-small-06.txt, 01-small-07.txt, 01-small-08.txt, 01-small-09.txt, 01-small-10.txt, 01-small-11.txt, 01-small-12.txt, 01-small-13.txt, 01-small-14.txt, 01-small-15.txt, 01-small-16.txt, 01-small-17.txt, 01-small-18.txt, 01-small-19.txt, 01-small-20.txt, 01-small-21.txt, 01-small-22.txt, 01-small-23.txt, 01-small-24.txt, 02-large-01.txt, 02-large-02.txt, 02-large-03.txt, 02-large-04.txt, 02-large-05.txt, 02-large-06.txt, 02-large-07.txt, 02-large-08.txt, 02-large-09.txt, 02-large-10.txt
Case Name Status Exec Time Memory
00-sample-01.txt AC 1 ms 3496 KiB
00-sample-02.txt AC 1 ms 3432 KiB
00-sample-03.txt AC 1 ms 3444 KiB
01-small-01.txt AC 1 ms 3508 KiB
01-small-02.txt AC 1 ms 3480 KiB
01-small-03.txt AC 1 ms 3436 KiB
01-small-04.txt AC 1 ms 3452 KiB
01-small-05.txt AC 1 ms 3644 KiB
01-small-06.txt AC 1 ms 3516 KiB
01-small-07.txt AC 1 ms 3448 KiB
01-small-08.txt AC 1 ms 3492 KiB
01-small-09.txt AC 1 ms 3504 KiB
01-small-10.txt AC 1 ms 3456 KiB
01-small-11.txt AC 1 ms 3564 KiB
01-small-12.txt AC 1 ms 3564 KiB
01-small-13.txt AC 1 ms 3440 KiB
01-small-14.txt AC 1 ms 3500 KiB
01-small-15.txt AC 1 ms 3528 KiB
01-small-16.txt AC 1 ms 3528 KiB
01-small-17.txt AC 1 ms 3584 KiB
01-small-18.txt AC 1 ms 3500 KiB
01-small-19.txt AC 1 ms 3712 KiB
01-small-20.txt AC 1 ms 3648 KiB
01-small-21.txt AC 1 ms 3584 KiB
01-small-22.txt AC 1 ms 3572 KiB
01-small-23.txt AC 1 ms 3532 KiB
01-small-24.txt AC 1 ms 3504 KiB
02-large-01.txt AC 25 ms 11376 KiB
02-large-02.txt AC 27 ms 9884 KiB
02-large-03.txt AC 17 ms 11396 KiB
02-large-04.txt AC 25 ms 9756 KiB
02-large-05.txt AC 27 ms 9836 KiB
02-large-06.txt AC 25 ms 9760 KiB
02-large-07.txt AC 27 ms 9744 KiB
02-large-08.txt AC 26 ms 9748 KiB
02-large-09.txt AC 25 ms 10496 KiB
02-large-10.txt AC 27 ms 9832 KiB