제출 #741744

#제출 시각아이디문제언어결과실행 시간메모리
741744Username4132Chorus (JOI23_chorus)C++14
40 / 100
7025 ms20760 KiB
#include<iostream> #include<vector> using namespace std; #define forn(i, n) for(int i=0; i<(int)n; ++i) #define dforn(i, n) for(int i=0; i<(int)n; ++i) #define forsn(i, s, n) for(int i=s; i<(int)n; ++i) #define PB push_back const int MAXN=5010, INF=1e7; int n, K, pos[MAXN], cost[MAXN][MAXN], dp[MAXN][MAXN]; char str[MAXN]; vector<bool> imp; int main(){ scanf("%d %d", &n, &K); scanf("%s", str); forn(i, n){ int cnA=0, cnB=0, cn=0; forn(j, 2*n){ if(str[j]=='A'){ cnA++; if(cnA>i) imp.PB(0); } else{ cnB++; if(cnB>i) imp.PB(1); } } forn(j, 2*(n-i)) if(!imp[j]) pos[cn++]=j; forsn(j, 1, cn+1) forn(k, j) cost[i][j]+=pos[k]-k; imp.clear(); } forn(i, n) dp[0][i]=INF; forsn(i, 1, K+1) dp[i][n]=INF; forsn(i, 1, K+1) dforn(j, n){ dp[i][j]=INF; forsn(k, 1, n-j+1) dp[i][j]=min(dp[i][j], dp[i-1][j+k] + cost[j][k]); } printf("%d\n", dp[K][0]); }

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

chorus.cpp: In function 'int main()':
chorus.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d %d", &n, &K);
      |     ~~~~~^~~~~~~~~~~~~~~~~
chorus.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%s", str);
      |     ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...