d539. 區間 MAX - 高中生程式解題系統
本文最後更新於:2024年1月12日 下午
Zerojudge
解題紀錄
d539. 區間 MAX - 高中生程式解題系統
// Author : ysh
// 09/14/2022 Wed 9:55:45.45
#include<bits/stdc++.h>
using namespace std;
#include<seg_tree>
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n;
vector<int>f(n);
for(int &i : f) {
cin>>i;
}
seg_tree<int>t(f,[] (int a,int b) {
return max(a,b);
});
int m;cin>>m;
int a,b;
while(m--) {
cin>>a>>b;
if(a > b) swap(a,b);
cout<<t.sum(a - 1,b - 1)<<"\n";
}
return 0;
}
d539. 區間 MAX - 高中生程式解題系統
http://mysh212.github.io/algosolution/Zerojudge-d539-5.cpp/