QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#165635#6857. Easy problem IIPPP#AC ✓908ms4452kbC++171.1kb2023-09-05 20:13:592023-09-05 20:14:00

Judging History

你现在查看的是最新测评结果

  • [2023-09-05 20:14:00]
  • 评测
  • 测评结果:AC
  • 用时:908ms
  • 内存:4452kb
  • [2023-09-05 20:13:59]
  • 提交

answer

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer","inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxN = 1e5 + 10;
ll a[maxN];
int n, m;
void solve() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    while (m--) {
        int op;
        cin >> op;
        int l, r;
        cin >> l >> r;
        if (op == 1) {
            ll x;
            cin >> x;
            for (int i = l; i <= r; i++) {
                a[i] = x + (a[i] >= x ? a[i] : -a[i]);
            }
        }
        else {
            ll ans = 0;
            for (int i = l; i <= r; i++) {
                ans += a[i];
            }
            cout << ans << '\n';
        }


    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    int tst;
    cin >> tst;
    while (tst--) {
        solve();
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 908ms
memory: 4452kb

input:

1
100000 100000
9994250 1 9999152 1 9996205 1 9993920 1 9992936 1 9999312 1 9994863 1 9999950 1 9994702 1 9998302 1 9997460 1 9995584 1 9990858 1 9995764 1 9992400 1 9992970 1 9993486 1 9992200 1 9991250 1 9990336 1 9994212 1 9992704 1 9999400 1 9994826 1 9996272 1 9995920 1 9994960 1 9996400 1 9990...

output:

474104664177
469903014249
480933011291
483822399944
484396591822
485195157450
476873328231
500050522935
490495899612
455001143708
459350186600
463088605817
452789422852
457530804729
478921256445
483860248443
460953094343
461203887676
471567676461
499102979676
483610787357
490750641096
468023668995
4...

result:

ok 85563 lines