답안 #1029815

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1029815 2024-07-21T11:06:55 Z vjudge1 Addk (eJOI21_addk) C++17
36 / 100
2000 ms 3652 KB
#include <bits/stdc++.h>
using namespace std;

#define SPEED ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define str string
#define pb push_back
#define pf push_front
#define nl "\n"
#define ll long long
#define int long long
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ff first
#define ss second
#define len(a) a.size()
#define pii pair<int,int>
const int N = 50000 + 101;
const int md = 998244353;
const int MOD = 1e8;
const int mega = 1e6 + 3;
const int inf = 1e9;

ll gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

ll lcm(int a, int b) {
    return (a / gcd(a, b)) * b;
}
void solve() {
    int n , k;
    cin >> n >> k;
    int a[n + 1];
    for(int i = 1; i <= n; ++i)cin >> a[i];
    int m;
    cin >> m;
    while(m--){
        int ty;
        cin >> ty;
        if(ty == 2){
            int l , r , m;
            cin >> l >> r >> m;
            int ans = 0;
            int pref[n + 1];
            pref[0] = 0;
            for (int i = l; i <= r; ++i) pref[i] = pref[i - 1] + a[i];
            for (int i = l; i <= r; ++i) {
                if (i <= r - m + 1) ans += pref[i + m - 1] - pref[i - 1];
            }
            cout << ans << "\n";
        }
        else{
            vector<int>v(k);
            for(int i = 0; i < k; ++i)cin >> v[i];
            int x = a[v[0]];
            for(int i = 0; i < k - 1; ++i) a[v[i]] = a[v[i + 1]];
            a[v.back()] = x;    
        }
    }
}

signed main() {
    SPEED;
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    #ifndef ONLINE_JUDGE
    cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 4 ms 348 KB Output is correct
4 Correct 11 ms 568 KB Output is correct
5 Correct 16 ms 600 KB Output is correct
6 Correct 23 ms 684 KB Output is correct
7 Correct 32 ms 604 KB Output is correct
8 Correct 44 ms 600 KB Output is correct
9 Correct 87 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 348 ms 1584 KB Output is correct
2 Correct 741 ms 1876 KB Output is correct
3 Correct 1388 ms 2588 KB Output is correct
4 Execution timed out 2068 ms 3256 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1480 ms 3408 KB Output is correct
2 Execution timed out 2035 ms 3652 KB Time limit exceeded
3 Halted 0 ms 0 KB -