제출 #1137060

#제출 시각아이디문제언어결과실행 시간메모리
1137060SulAAddk (eJOI21_addk)C++20
36 / 100
2095 ms1348 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define bitcount __builtin_popcountll #define all(a) (a).begin(), (a).end() using namespace std; using namespace __gnu_pbds; using namespace chrono; template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define ulong unsigned long long #define uint unsigned int signed main() { ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); int n,k; cin>>n>>k; int a[n]; for (int& x : a) cin>>x; int q; cin>>q; while (q--) { int t; cin>>t; if (t == 1) { for (int i = 0; i < k; i++) cin>>t; } else { int l,r,m; cin>>l>>r>>m; l--, r--; int len = r-l+1; long long ans = 0; for (int i = l; i <= r; i++) ans += 1LL * min({len-m+1, m, i-l+1, r-i+1}) * a[i]; cout<<ans<<'\n'; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...