結果
| 問題 |
No.1234 典型RMQ
|
| コンテスト | |
| ユーザー |
carrot46
|
| 提出日時 | 2020-09-18 23:08:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,154 bytes |
| コンパイル時間 | 1,637 ms |
| コンパイル使用メモリ | 172,852 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-20 00:55:01 |
| 合計ジャッジ時間 | 9,666 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 RE * 21 |
ソースコード
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);
template<class T> bool chmin(T &a, const T &b){
if(a > b) {a = b; return true;}
else return false;
}
template<class T> bool chmax(T &a, const T &b){
if(a < b) {a = b; return true;}
else return false;
}
const int sz = 317, num = 317;
struct node{
vec a;
ll plus, mini;
int L, R;
node(){}
node(int id, vec &_a) : a(sz), plus(0), mini(INF), L(id * sz), R((id + 1) * sz){
rep(i, sz) a[i] = (i + id * sz < (int)_a.size() ? _a[i + id * sz] : INF);
mini = *min_element(ALL(a));
}
void eval(bool mini_update = true){
rep(i, sz) a[i] += plus;
plus = 0;
mini = *min_element(ALL(a));
}
void update(int l, int r, ll c){
if(R <= l || r <= L) return;
if(l <= L && R <= r){
plus += c;
}else{
eval(false);
reps(i, max(L, l), min(R, r)) a[i] += c;
mini = *min_element(ALL(a));
}
}
ll query(int l, int r){
if(R <= l || r <= L) return INF;
if(l <= L && R <= r){
return mini + plus;
}else{
eval();
ll res(INF);
reps(i, max(L, l), min(R, r)) chmin(res, a[i]);
return res;
}
}
};
int main() {
cin>>N;
vec a(N);
vector<node> group(num);
rep(i, N) cin>>a[i];
rep(i, num) group[i] = node(i, a);
cin>>Q;
rep(_, Q){
int k, l, r, c;
cin>>k>>l>>r>>c;
--l;
if(k == 1){
rep(i, num) group[i].update(l, r, c);
}else{
ll res(INF);
rep(i, num) chmin(res, group[i].query(l, r));
cout<<res<<endl;
}
}
}
carrot46