Submission #1276062

#TimeUsernameProblemLanguageResultExecution timeMemory
1276062burnthememoryBubble Sort Machine (JOI25_bubble)C++20
0 / 100
2095 ms14140 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];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	ll q; cin >> q;

	while(q--){
		ll que; cin >> que;
		if(que == 1){
			for(int i = 1; i < n; i++){
				if(a[i-1] > a[i]){
					swap(a[i-1], a[i]);
				}
			}
		}else{
			ll l, r;
			cin >> l >> r;
			l--; r--;
			ll ans = 0;
			for(int i = l; i <= r; i ++){
				ans += a[i];
			}

			cout << ans << 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...