Submission #69511

# Submission time Handle Problem Language Result Execution time Memory
69511 2018-08-21T06:56:38 Z octopuses Election (BOI18_election) C++17
0 / 100
5 ms 376 KB
//Giorgi Kldiashvili

#include <bits/stdc++.h>

#define ll long long
#define fr first
#define sc second
#define M 1000000007ll

using namespace std;

const int N = 50020;

char ch[N];
int L[N], R[N];
int n, m, l, r;
int A, B;

int main()
{
  scanf("%d\n", &n);
  scanf("%s", &ch);
  for(int i = 1; i <= n; ++ i)
  {
    int x = (ch[i - 1] == 'C')?1:-1;
    L[i] = L[i - 1] + x;
  }
  for(int i = n; i >= 1; -- i)
  {
    int x = (ch[i - 1] == 'C')?1:-1;
    R[i] = R[i + 1] + x;
  }
  scanf("%d", &m);
  while(m --)
  {
    scanf("%d %d", &l, &r);
    A = n; B = n;
    for(int i = l; i <= r; ++ i)
    {
      A = min(A, L[i]);
      B = min(B, R[i]);
    }
    printf("%d\n", max(L[l - 1] - A, R[r + 1] - B));
  }
}

Compilation message

election.cpp: In function 'int main()':
election.cpp:22:18: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[50020]' [-Wformat=]
   scanf("%s", &ch);
               ~~~^
election.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d\n", &n);
   ~~~~~^~~~~~~~~~~~
election.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", &ch);
   ~~~~~^~~~~~~~~~~
election.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &m);
   ~~~~~^~~~~~~~~~
election.cpp:36: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 time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -