Submission #693332

#TimeUsernameProblemLanguageResultExecution timeMemory
693332rainboyToilets (JOI16_toilets)C11
100 / 100
20 ms1364 KiB
#include <stdio.h> #include <string.h> #define N 200000 long long max(long long a, long long b) { return a > b ? a : b; } int main() { int m; long long n, sum_, suf_; scanf("%lld%d", &n, &m); sum_ = 0, suf_ = 0; while (m--) { static char cc[N + 1]; int n, i; long long k, sum, suf; scanf("%s%lld", cc, &k), n = strlen(cc); sum = suf = 0; for (i = 0; i < n; i++) { sum += cc[i] == 'M' ? 1 : -1; if ((suf += (cc[i] == 'M' ? 1 : -1)) < 0) suf = 0; } sum_ += sum * k, suf_ = max(suf_ + sum * k, max(sum * (k - 1), 0) + suf); } printf("%lld\n", sum_ > 0 ? -1 : (suf_ == 0 ? 0 : suf_ - 1)); return 0; }

Compilation message (stderr)

toilets.c: In function 'main':
toilets.c:12:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%lld%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~~~
toilets.c:19:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   scanf("%s%lld", cc, &k), n = strlen(cc);
      |   ^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...