제출 #63649

#제출 시각아이디문제언어결과실행 시간메모리
63649Just_Solve_The_ProblemElection (BOI18_election)C++11
0 / 100
8 ms376 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int N = (int)2e3 + 7;

int used[N];

main() {
  int n;
  string s;
  scanf("%d", &n);
  cin >> s;
  s = " " + s;
  int q;
  scanf("%d", &q);
  while (q--) {
    int l, r;
    int ans = 0;
    scanf("%d %d", &l, &r);
    int b = 0;
    int res = 0;
    for (int i = l; i <= r; i++) {
      b += ((s[i] == 'T') ? -1 : 1);
      if (b < 0) {
        res++;
        b++;
      }
    }
    ans = max(ans, res);
    res = 0;
    b = 0;
    for (int i = r; i >= l; i--) {
      b += ((s[i] == 'T') ? -1 : 1);
      if (b < 0) {
        res++;
        b++;
      }
    }
    ans = max(ans, res);
    printf("%d\n", ans);
  }
}

컴파일 시 표준 에러 (stderr) 메시지

election.cpp:11:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
election.cpp: In function 'int main()':
election.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
   ~~~~~^~~~~~~~~~
election.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &q);
   ~~~~~^~~~~~~~~~
election.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &l, &r);
     ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...