제출 #91102

#제출 시각아이디문제언어결과실행 시간메모리
91102emil_physmathMoney (IZhO17_money)C++14
45 / 100
1543 ms5900 KiB
#include <iostream> #include <stdio.h> #include <algorithm> #include <set> using namespace std; int a[1000005], dp[1000005]; int main() { int n; cin>>n; for (int k=0; k<n; k++) scanf("%d", a+k); set<int>curSorted; for (int i=0; i<n; i++) { dp[i]=i+1; for (int j=i; j>=0; j--) { if (j<i && a[j]>a[j+1]) break; curSorted.clear(); curSorted.insert(0); curSorted.insert(10000000); for (int k=0; k<j; k++) curSorted.insert(a[k]); if (a[i]<=*curSorted.upper_bound(a[j])) dp[i]=min(dp[i], dp[j-1]+1); } } cout<<dp[n-1]<<'\n'; //int i=0, ans=0; //set<int> curSorted; //curSorted.insert(0); //curSorted.insert(10000000); //while (i<n) //{ // ans++; // int j=i; // while (j+1<n && a[j+1]>a[j]) // j++; // auto rBound=curSorted.upper_bound(a[i]); // j=upper_bound(a+i, a+j+1, *rBound)-a; // for (int k=i; k<j; k++) // curSorted.insert(a[k]); // i=j; //} //cout<<ans<<'\n'; char I; cin >> I; return 0; } /* 9 2 5 4 3 5 6 4 6 7 5 1 2 4 3 5 */

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

money.cpp: In function 'int main()':
money.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", a+k);
   ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...