結果
| 問題 | No.935 う し た ぷ に き あ く ん 笑 ビ - ム |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2019-11-30 00:05:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 1,153 bytes |
| 記録 | |
| コンパイル時間 | 610 ms |
| コンパイル使用メモリ | 85,452 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-14 05:54:54 |
| 合計ジャッジ時間 | 2,588 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 58 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:47:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
47 | scanf("%d%s", &n, s);
| ~~~~~^~~~~~~~~~~~~~~
main.cpp:51:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
51 | scanf("%d", &ai);
| ~~~~~^~~~~~~~~~~
main.cpp:57:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
57 | scanf("%d", &q);
| ~~~~~^~~~~~~~~~
main.cpp:61:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
61 | scanf("%d", &k);
| ~~~~~^~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 935.cc: No.935 う し た ぷ に き あ く ん 笑 ビ - ム - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 2000;
/* typedef */
typedef long long ll;
/* global variables */
char s[MAX_N + 4];
ll as[MAX_N + 1];
int es[MAX_N + 1];
/* subroutines */
/* main */
int main() {
int n;
scanf("%d%s", &n, s);
for (int i = 0; i < n; i++) {
int ai;
scanf("%d", &ai);
as[i + 1] = as[i] + ai;
es[i + 1] = es[i] + ((s[i] == 'E') ? 1 : 0);
}
int q;
scanf("%d", &q);
while (q--) {
int k;
scanf("%d", &k);
int maxl = 0;
for (int i = 0, j = 0; i < n; i++) {
while (j < n && as[j + 1] - as[i] <= k) j++;
int l = es[j] - es[i];
if (maxl < l) maxl = l;
}
printf("%d\n", maxl);
}
return 0;
}
tnakao0123