답안 #63513

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
63513 2018-08-02T05:05:43 Z Just_Solve_The_Problem Election (BOI18_election) C++11
0 / 100
6 ms 376 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

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, b1 = 0;;
    for (int i = l; i <= r; i++) {
      b += (s[i] == 'T' ? -1 : 1);
      ans = min(ans, b);
      b1 += (s[r - i + 1] == 'T' ? -1 : 1);
      ans = min(ans, b1);
    }
    ans *= -1;
    printf("%d\n", ans);
  }
}

Compilation message

election.cpp:7:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
election.cpp: In function 'int main()':
election.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
   ~~~~~^~~~~~~~~~
election.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &q);
   ~~~~~^~~~~~~~~~
election.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &l, &r);
     ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -