Submission #1067421

#TimeUsernameProblemLanguageResultExecution timeMemory
1067421vjudge1Money (IZhO17_money)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pii pair<int,int> #define pll pair<ll,ll> #define fi first #define se second const int maxN=1e6+5; const ll inf=2e18; int n,a[maxN+1],pre[maxN+1]; set<ll> se; int main() { //freopen("","r",stdin); //freopen("","w",stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; pre[i]=-1; } int pos=-1; se.insert(inf); se.insert(a[1]); for(int i=2;i<=n;i++) { if(a[i]<a[i-1]) { pos=i; break; } else se.insert(a[i]); } int cnt=1; if(pos==-1) { cout<<cnt; return 0; } cnt++; auto itr=se.upper_bound(a[pos]); int i=pos+1; ll base=(*itr); se.insert(a[pos]); while(i<=n) { while(i<=n&&a[i]>=a[i-1]&&(*se.lower_bound(a[i]))<=base) { se.insert(a[i]); i++; } //cout<<i<<" "<<cnt<<" "<<base<<'\n'; if(i<=n) { cnt++; base=(*se.upper_bound(a[i])); se.insert(a[i]); //cout<<i<<" "<<(*se.upper_bound(a[i]))<<'\n'; i++; } } cout<<cnt; } /*20 324662 468027 324662 324662 468027 324662 468027 324662 324662 468027 963343 944165 165047 127072 405908 918630 854332 571550 909067 448963*/ #include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pii pair<int,int> #define pll pair<ll,ll> #define fi first #define se second const int maxN=1e6+5; const ll inf=2e18; int n,a[maxN+1],pre[maxN+1]; set<ll> se; int main() { //freopen("","r",stdin); //freopen("","w",stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; pre[i]=-1; } int pos=-1; se.insert(inf); se.insert(a[1]); for(int i=2;i<=n;i++) { if(a[i]<a[i-1]) { pos=i; break; } else se.insert(a[i]); } int cnt=1; if(pos==-1) { cout<<cnt; return 0; } cnt++; auto itr=se.upper_bound(a[pos]); int i=pos+1; ll base=(*itr); se.insert(a[pos]); while(i<=n) { while(i<=n&&a[i]>=a[i-1]&&(*se.lower_bound(a[i]))<=base) { se.insert(a[i]); i++; } //cout<<i<<" "<<cnt<<" "<<base<<'\n'; if(i<=n) { cnt++; base=(*se.upper_bound(a[i])); se.insert(a[i]); //cout<<i<<" "<<(*se.upper_bound(a[i]))<<'\n'; i++; } } cout<<cnt; } /*20 324662 468027 324662 324662 468027 324662 468027 324662 324662 468027 963343 944165 165047 127072 405908 918630 854332 571550 909067 448963*/

Compilation message (stderr)

money.cpp:78:11: error: redefinition of 'const int maxN'
   78 | const int maxN=1e6+5;
      |           ^~~~
money.cpp:9:11: note: 'const int maxN' previously defined here
    9 | const int maxN=1e6+5;
      |           ^~~~
money.cpp:79:10: error: redefinition of 'const long long int inf'
   79 | const ll inf=2e18;
      |          ^~~
money.cpp:10:10: note: 'const long long int inf' previously defined here
   10 | const ll inf=2e18;
      |          ^~~
money.cpp:80:5: error: redefinition of 'int n'
   80 | int n,a[maxN+1],pre[maxN+1];
      |     ^
money.cpp:11:5: note: 'int n' previously declared here
   11 | int n,a[maxN+1],pre[maxN+1];
      |     ^
money.cpp:80:7: error: redefinition of 'int a [1000006]'
   80 | int n,a[maxN+1],pre[maxN+1];
      |       ^
money.cpp:11:7: note: 'int a [1000006]' previously declared here
   11 | int n,a[maxN+1],pre[maxN+1];
      |       ^
money.cpp:80:17: error: redefinition of 'int pre [1000006]'
   80 | int n,a[maxN+1],pre[maxN+1];
      |                 ^~~
money.cpp:11:17: note: 'int pre [1000006]' previously declared here
   11 | int n,a[maxN+1],pre[maxN+1];
      |                 ^~~
money.cpp:77:12: error: redefinition of 'std::set<long long int> second'
   77 | #define se second
      |            ^~~~~~
money.cpp:81:9: note: in expansion of macro 'se'
   81 | set<ll> se;
      |         ^~
money.cpp:8:12: note: 'std::set<long long int> second' previously declared here
    8 | #define se second
      |            ^~~~~~
money.cpp:12:9: note: in expansion of macro 'se'
   12 | set<ll> se;
      |         ^~
money.cpp:82:5: error: redefinition of 'int main()'
   82 | int main()
      |     ^~~~
money.cpp:13:5: note: 'int main()' previously defined here
   13 | int main()
      |     ^~~~