UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#211086#2407. 双端队列rua05ms1264kbC++111.1kb2024-08-09 10:46:152024-08-09 12:45:29

answer

#include <bits/stdc++.h>
#define inf INT_MAX
#define NN INT_MIN
typedef long long ll;
using namespace std;
int q[10000000];
int r = 5000000, l = 5000001;
int main()
{
#ifdef WHX_AK_IOI
   freopen("data.in", "r", stdin);
// freopen("dataout.txt","w",stdout);
#endif
   ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   int T;
   cin >> T;
   while (T--)
   {
      int op;
      cin >> op;
      if (op == 1)
      {
         int x;
         cin >> x;
         q[++r] = x;
      }
      if (op == 2)
      {
         int x;
         cin >> x;
         q[--l] = x;
      }
      if (op == 3)
         r--;
      if (op == 4)
         l++;
      if (op == 5)
      {
         int k, c;
         cin >> k >> c;
         int sum = 0;
         for (int i = 0; i <= c - 1; i++)
            sum += q[r - i * k];
         cout << sum << endl;
      }
      if (op == 6)
      {
         int k, c;
         cin >> k >> c;
         int sum = 0;
         for (int i = 0; i <= c - 1; i++)
            sum += q[l + i * k];
         cout << sum << endl;
      }
   }
   // system("pause");
   return 0;
}

详细

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 5ms
memory: 1264kb

input:

3000
2 -219498
2 -293012
2 340429
2 282883
2 17839
2 300008
2 -275152
2 -328138
2 337993
2 -149230
2...

output:

-529420
308873
-346656
-375516
-378742
243014
-2505874
907290
84617
-201764
-1311674
-1056004
112539...

result:

wrong answer 10th lines differ - expected: '-501772', found: '-201764'

Subtask #2:

score: 0
Wrong Answer

Test #7:

score: 0
Wrong Answer
time: 0ms
memory: 1260kb

input:

3000
2 -219498
2 -293012
2 340429
2 282883
2 17839
2 300008
2 -275152
2 -328138
2 337993
2 -149230
2...

output:

-529420
308873
-346656
-375516
-378742
243014
-2505874
907290
84617
-201764
-1311674
-1056004
112539...

result:

wrong answer 10th lines differ - expected: '-501772', found: '-201764'

Subtask #3:

score: 0
Time Limit Exceeded

Test #19:

score: 0
Time Limit Exceeded

input:

3000000
1 109596
1 18831
2 89913
1 -164180
2 -256425
2 179608
2 -41750
1 245023
1 185637
1 79804
2 -...

output:

474711
-346102
128379
-193118
-93743
-265084
313689
-18092
-94553
892922
28562
96170
-454664
-270538...

result:


Subtask #4:

score: 0
Time Limit Exceeded

Test #24:

score: 0
Time Limit Exceeded

input:

3000000
1 109596
1 18831
2 89913
1 -164180
2 -256425
2 179608
2 -41750
1 245023
1 185637
1 79804
2 -...

output:

474711
-346102
128379
-193118
-93743
-265084
313689
-18092
-94553
892922
28562
96170
-454664
-270538...

result:


Subtask #5:

score: 0
Wrong Answer

Test #34:

score: 0
Wrong Answer
time: 0ms
memory: 1260kb

input:

3000
2 -219498
2 -293012
2 340429
2 282883
2 17839
2 300008
2 -275152
2 -328138
2 337993
2 -149230
2...

output:

-529420
308873
-346656
-375516
-378742
243014
-2505874
907290
84617
-201764
-1311674
-1056004
112539...

result:

wrong answer 10th lines differ - expected: '-501772', found: '-201764'