Submission #537143

# Submission time Handle Problem Language Result Execution time Memory
537143 2022-03-14T15:49:32 Z Xiaoyang Global Warming (NOI13_gw) C++17
0 / 40
228 ms 33276 KB
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define endl "\n"
#define pb push_back
#define MP make_pair
#define ll long long
#define int long long
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define pq priority_queue
#define gcd(x,y) __gcd( x, y)
#define ALL(x) x.begin(),x.end()
#define pll pair<long long,long long>
#define debug(x) cerr<<#x<<"="<<x<<endl
#define rep(i,a,b) for (int i=a;i<(int)(b);i++)
typedef tree<long long, null_type, less_equal<long long>,rb_tree_tag, tree_order_statistics_node_update>ordered_set;
int lowbit(int x){return x&(-x);}
long long expo(ll x,ll y,ll z){if(y==1)return (long long)x;ll m=expo(x,y/2,z)%z;if(y%2==0)return (long long)((m*m)%z);else return (long long)((((m*m)%z)*x)%z);}
int fw[1000005];void update(int x,int c){while(x<=1000005){fw[x]=fw[x]+c;x+=lowbit(x);}}int query(int x){int ans=0;while(x>=1){ans+=fw[x];x-=lowbit(x);}return ans;}

int blist[1000009];
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,x,ans=0;cin>>n;
	vector<pii>alist;
	rep(i,0,n){
		int a;cin>>a;
		alist.pb({a,i});
	}
	sort(ALL(alist));
    reverse(ALL(alist));
	rep(i,0,n){
		blist[alist[i].se]=1;
		if(alist[i].se>0)x-=blist[alist[i].se-1];
		if(alist[i].se<n-1)x-=blist[alist[i].second+1];
      	x++;
		if(i!=n-1 and alist[i].fi>alist[i+1].fi)ans=max(ans, x);
	}
	cout<<ans;
    return 0;
}

Compilation message

gw.cpp: In function 'int main()':
gw.cpp:43:21: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |   if(alist[i].se>0)x-=blist[alist[i].se-1];
      |                    ~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 3056 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 3708 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 228 ms 33276 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 219 ms 32536 KB Output isn't correct
2 Halted 0 ms 0 KB -