C. Dima and Staircase(思维)
生活随笔
收集整理的這篇文章主要介紹了
C. Dima and Staircase(思维)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
題目鏈接————
類似于俄羅斯方塊,但是每次方塊的左端點(diǎn)總在最左,讓你輸出每個(gè)方塊落下時(shí)的高度。
思路:這個(gè)題目很重要的兩點(diǎn),一個(gè)是每次方塊都靠最左,二是給的樓梯都是遞增的。
所以綜上兩點(diǎn),只需要維護(hù)一個(gè)最大高度就可以。
AC Code:
#include <iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll;ll res[100010]; int main() {ios::sync_with_stdio(false);ll s,n,k,t;cin>>n;for(int i= 1;i<=n;++i){cin>>res[i];}cin>>k;ll MAX = 0;for(int i=1;i<=k;++i){cin>>s>>t;MAX = max(res[s],MAX);cout<<MAX<<endl;MAX += t;} }?
總結(jié)
以上是生活随笔為你收集整理的C. Dima and Staircase(思维)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: TensorFlow学习(三)——神经网
- 下一篇: 养生食物库隐私政策