結果
| 問題 |
No.833 かっこいい電車
|
| コンテスト | |
| ユーザー |
aya_se
|
| 提出日時 | 2019-05-25 00:06:53 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,160 bytes |
| コンパイル時間 | 677 ms |
| コンパイル使用メモリ | 71,896 KB |
| 実行使用メモリ | 15,184 KB |
| 最終ジャッジ日時 | 2024-07-02 03:49:49 |
| 合計ジャッジ時間 | 7,432 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | TLE * 1 -- * 29 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <iomanip>
int ctoi(char c) {
switch (c) {
case '0': return 0;
case '1': return 1;
case '2': return 2;
case '3': return 3;
case '4': return 4;
case '5': return 5;
case '6': return 6;
case '7': return 7;
case '8': return 8;
case '9': return 9;
default: return 0;
}
}
using namespace std;
typedef long long ll;
//定義場所//
int i, j, k, l, m, n;
int N, Q;
vector<ll> A;
vector<int> border;//i両目の右隣に仕切り
vector<ll> Ans;
////////////
int main()
{
cin >> N >> Q;
for (i = 0; i < N; i++) {
ll a;
cin >> a;
A.push_back(a);
border.push_back(1);
}
for (i = 0; i < Q; i++) {
int q;
int x;
cin >> q >> x;
if (q == 1) {
border[x - 1] = 0;
}
else if (q == 2) {
border[x - 1] = 1;
}
else if (q == 3) {
A[x - 1]++;
}
else {
ll ans = A[x - 1];
j = x - 1;
while (j>0 && border[j-1]==0) {
ans += A[j - 1];
j--;
}
j = x - 1;
while (j < N-1 && border[j] == 0) {
ans += A[j + 1];
j++;
}
Ans.push_back(ans);
}
}
for (i = 0; i < Ans.size(); i++) {
cout << Ans[i] << endl;
}
}
aya_se