| Task: | Sums |
| Sender: | team_a |
| Submission time: | 2020-10-03 14:29:41 +0300 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | TIME LIMIT EXCEEDED |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | details |
| #2 | ACCEPTED | 0.01 s | details |
| #3 | ACCEPTED | 0.01 s | details |
| #4 | ACCEPTED | 0.01 s | details |
| #5 | ACCEPTED | 0.01 s | details |
| #6 | TIME LIMIT EXCEEDED | -- | details |
| #7 | TIME LIMIT EXCEEDED | -- | details |
| #8 | TIME LIMIT EXCEEDED | -- | details |
| #9 | TIME LIMIT EXCEEDED | -- | details |
| #10 | TIME LIMIT EXCEEDED | -- | details |
Code
#include <iostream>
using namespace std;
void inc(int *v, int a, int b, int x) {
int i = a - 1;
while((b - i) % 4) {
v[i] += x;
i++;
}
for (; i < b; i += 4) {
v[i] += x;
v[i + 1] += x;
v[i + 2] += x;
v[i + 3] += x;
}
}
void set(int *v, int a, int b, int x) {
int i = a - 1;
while((b - i) % 4) {
v[i] = x;
i++;
}
for (; i < b; i += 4) {
v[i] = x;
v[i + 1] = x;
v[i + 2] = x;
v[i + 3] = x;
}
}
void sum(int *v) {
int a, b;
cin >> a >> b;
int i = a - 1;
long int t0 = 0;
long int t1 = 0;
long int t2 = 0;
long int t3 = 0;
while((b - i) % 4) {
t0 += v[i];
i++;
}
for (; i < b; i += 4) {
t0 += v[i + 0];
t1 += v[i + 1];
t2 += v[i + 2];
t3 += v[i + 3];
}
cout << (t0 + t1 + t2 + t3) << endl;
}
int main() {
std::ios::sync_with_stdio(0);
int n;
cin >> n;
int *v = new int[n]; // Values
for (int i = 0; i < n; i++) cin >> v[i];
int q;
cin >> q;
int *qs = new int[4*q]; // Values
int j = 0;
for(int i = 0; i < q; i++) {
int o;
cin >> o;
if (o == 3) {
for (int qi = j; qi < i; qi++) {
int a = qs[4*qi + 1];
int b = qs[4*qi + 2];
int x = qs[4*qi + 3];
if (qs[4*qi] == 1)
inc(v, a, b, x);
else
set(v, a, b, x);
}
j = i + 1;
sum(v);
} else {
qs[4*i + 0] = o;
cin >> qs[4*i + 1];
cin >> qs[4*i + 2];
cin >> qs[4*i + 3];
}
}
return 0;
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 10 -10 3 -1 4 4 1 6 7 9 3 20 2 7 10 -5 2 5 9 2 ... |
| correct output |
|---|
| -2 32 10 13 12 |
| user output |
|---|
| -2 32 10 13 12 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 10 -10 -4 -7 -2 5 -8 0 -5 -5 5 20 3 8 10 1 5 6 7 ... |
| correct output |
|---|
| -5 12 7 -13 -33 ... |
| user output |
|---|
| -5 12 7 -13 -33 ... |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 10 0 -2 7 4 1 4 -5 8 9 -10 20 2 2 8 -5 2 8 9 -2 ... |
| correct output |
|---|
| -17 -10 -12 -5 21 |
| user output |
|---|
| -17 -10 -12 -5 21 |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 10 0 6 -6 -9 7 -9 2 6 -4 -8 20 1 8 10 9 2 2 6 -10 ... |
| correct output |
|---|
| 6 30 -30 -9 |
| user output |
|---|
| 6 30 -30 -9 |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 10 -8 6 0 8 1 -8 3 6 10 -6 20 2 5 7 -3 3 2 4 ... |
| correct output |
|---|
| 14 18 7 29 -20 |
| user output |
|---|
| 14 18 7 29 -20 |
Test 6
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 273768 -746242 141310 -177646 ... |
| correct output |
|---|
| 6647300100 16584491568 2201217278 4428835910 -5370398949 ... |
| user output |
|---|
| (empty) |
Test 7
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 -371240 -967819 -659618 -83603... |
| correct output |
|---|
| -8551444 -14584129201 -9051387 1006850011 -1119500762 ... |
| user output |
|---|
| (empty) |
Test 8
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 954118 382497 -92991 199841 98... |
| correct output |
|---|
| -31591117 3979951718 1018552734 1672204000 230714784 ... |
| user output |
|---|
| (empty) |
Test 9
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 -374041 -712493 -568255 490384... |
| correct output |
|---|
| 9993656711 4138033702 8839287 3596183407 -643074001 ... |
| user output |
|---|
| (empty) |
Test 10
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 100000 257414 -141188 -721927 -67385 ... |
| correct output |
|---|
| -47022095 -13947364 19483822021 10788657040 -4163257456 ... |
| user output |
|---|
| (empty) |
