zoukankan      html  css  js  c++  java
  • 0.0

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    using namespace std;
    //Mystery_Sky
    //
    #define M 201000
    #define INF 0x3f3f3f3f
    #define ll long long
    inline int read()
    {
    	int x=0,f=1;char c=getchar();
    	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    	return x*f;
    }
    struct node{
    	int x, t;
    }Q[M];
    int n, q, a[M], c[M];
    int max_r[M];
    
    int main() {
    //	freopen("bill.in", "r", stdin);
    //	freopen("bill.out", "w", stdout);
    	n = read();
    	for(int i = 1; i <= n; i++) a[i] = read();
    	q = read();
    	int tot = 0;
    	for(int i = 1; i <= q; i++) {
    		int opt = read();
    		if(opt == 1) {
    			int p = read(), x = read();
    			a[p] = x;
    			c[p] = i;
    		}
    		else {
    			int x = read();
    			Q[++tot].t = i;
    			Q[tot].x = x;
    		}
    	}
    	if(tot == q - Q[1].t + 1) {//只在1后出现2
    		int maxx = -1; 
    		for(int i = 1; i <= tot; i++) maxx = max(Q[i].x, maxx);
    		for(int i = 1; i <= n; i++) {
    			if(a[i] < maxx) a[i] = maxx;
    			printf("%d ", a[i]);	
    		}
    	}
    	else {
    		int m = tot;
    		for(int i = q; i >= 1; i--) {
    			if(Q[m].t == i) {
    				max_r[i] = max(Q[m].x, max_r[i+1]);
    				m--;
    			}
    			else max_r[i] = max_r[i+1];
    		}
    		for(int i = 1; i <= n; i++) {
    			if(c[i] == 0) a[i] = max(a[i], max_r[1]);
    			else a[i] = max(a[i], max_r[c[i]]);
    			printf("%d ", a[i]);
    		}
    	}
    	return 0;
    }
    
  • 相关阅读:
    Base64 编解码
    MFC:CTime类和CTimeSpan类
    VC对话框实现添加滚动条实现滚动效果
    组合框控件 -- CComboBox
    快速排序
    归并排序
    插入排序
    堆排序
    Mozilla新特性只支持https网站,再次推动SSL证书普及
    企业如何选择最佳的SSL
  • 原文地址:https://www.cnblogs.com/Benjamin-cpp/p/11845643.html
Copyright © 2011-2022 走看看