제출 #1276066

#제출 시각아이디문제언어결과실행 시간메모리
1276066burnthememoryBubble Sort Machine (JOI25_bubble)C++20
5 / 100
2095 ms25312 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define mp make_pair #define fi first #define se second const ll N = 1e5*2 + 10; vector<vector<ll>> adj(N); vector<vector<ll>> dp(2, vector<ll> (N, 1)); ll MOD = 1e9+7; vector<ll> vis(N, 0); void solve(){ ll n; cin >> n; ll a[n+10]; for(int i = 0; i < n; i++){ cin >> a[i+1]; } ll q; cin >> q; vector<ll> pref(n+1, 0); for(int i = 1; i <= n; i++){ pref[i] = pref[i-1] + a[i]; } while(q--){ ll que; cin >> que; if(que == 1){ for(int i = 2; i <= n; i++){ if(a[i-1] > a[i]){ swap(a[i-1], a[i]); } } for(int i = 1; i <= n; i++){ pref[i] = pref[i-1] + a[i]; } }else{ ll l, r; cin >> l >> r; cout << pref[r]-pref[l-1] << endl; } } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll t=1; // cin >> t; while(t--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...