Submission #171543

#TimeUsernameProblemLanguageResultExecution timeMemory
171543juggernautMoney (IZhO17_money)C++14
45 / 100
1538 ms58144 KiB
//Just try and the idea will come! #include<bits/stdc++.h> using namespace std; set<int>st; int mx,n,i,a[1000001],ans; main(){ st.insert(1e8); scanf("%lld",&n); for(i=0;i<n;i++)scanf("%lld",&a[i]); i=0; while(i<n){ mx=*st.upper_bound(a[i]); st.insert(a[i]); while(i+1<n&&a[i]<=a[i+1]&&a[i+1]<=mx)i++,st.insert(a[i]); i++; ans++; } printf("%lld",ans); }

Compilation message (stderr)

money.cpp:6:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
money.cpp: In function 'int main()':
money.cpp:8:20: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
     scanf("%lld",&n);
                  ~~^
money.cpp:9:39: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
     for(i=0;i<n;i++)scanf("%lld",&a[i]);
                                  ~~~~~^
money.cpp:18:22: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int' [-Wformat=]
     printf("%lld",ans);
                      ^
money.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
     ~~~~~^~~~~~~~~~~
money.cpp:9:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=0;i<n;i++)scanf("%lld",&a[i]);
                     ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...