제출 #381206

#제출 시각아이디문제언어결과실행 시간메모리
381206patrikpavic2Toilets (JOI16_toilets)C++17
36 / 100
27 ms1900 KiB
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long ll; const int N = 2e5 + 500; ll n, P, S, cF; int m, k; char s[N]; int main(){ scanf("%lld%d", &n, &m); for(;m--;){ ll PP = 0, SS = 0, cFF = 0, kol; scanf("%s %lld", s, &kol); k = strlen(s); for(int i = 0;i < k;i++){ SS += (s[i] == 'F' ? -1 : 1); cFF += (s[i] == 'F'); PP = min(PP, SS); } cF += cFF * kol; P = min(PP, S + PP + max(0LL, (kol - 1) * SS)); S += SS * kol; } if(cF < n) printf("-1\n"); else printf("%lld\n", max(0LL, (2LL * n - 2LL * cF - 1) - P)); return 0; }

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

toilets.cpp: In function 'int main()':
toilets.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |  scanf("%lld%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~~
toilets.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |   scanf("%s %lld", s, &kol); k = strlen(s);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...