Submission #656352

#TimeUsernameProblemLanguageResultExecution timeMemory
656352aSSSdDischarging (NOI20_discharging)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rnd(int l,int r) { return l+rng()%(r-l+1); } #define fasty ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define forinc(x,a,b) for(int x=a;x<=b;x++) #define fordec(x,a,b) for(int x=a;x>=b;x--) #define iii pair<ii,int> #define fi first #define se second #define ii pair<int,int> #define getbit(x,i) ((x>>(i))&1) #define batbit(x,i) (x|(1ll<<(i))) #define tatbit(x,i) (x&~(1<<(i))) #define endl '\n' #define pb push_back #define int long long const int N = 1e6 + 10; int n, t[N]; int f[N][23]; int lg[N]; int dp[N]; int get(int l, int r) { int p = lg[r-l+1]; return max(f[l][p] , f[r - (1<<p) + 1][p]); } int cost(int j, int i) { return dp[j] + get(j+1,i)*(n-j); } int inc=1; int dec=1; main() { //freopen("task.inp" , "r" , stdin); fasty; cin >> n; forinc(i,1,n) { cin >> t[i]; f[i][0] = t[i]; } forinc(i,1,n-1) { if(t[i] > t[i+1]) inc=0; if(t[i] < t[i+1]) dec=0; } forinc(i,2,n) lg[i] = lg[i/2] + 1; forinc(j,1,20) { for(int i=1 ; i + (1<<j) - 1 <= n ; i++) { f[i][j] = max(f[i][j-1] , f[i + (1<<(j-1) )][j-1]); } } if(n<=7000) { memset(dp , 127, sizeof dp); dp[0]=0; forinc(i,1,n) { fordec(j,i-1,0) dp[i] = min(dp[i] ,cost(j,i)); } cout << dp[n]; return 0; } if(dec == 1) { int sum=0; int res = a[1] * n; cout << res << "\n"; return 0; } }

Compilation message (stderr)

Discharging.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 | main()
      | ^~~~
Discharging.cpp: In function 'int main()':
Discharging.cpp:50:27: error: reference to 'dec' is ambiguous
   50 |         if(t[i] < t[i+1]) dec=0;
      |                           ^~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from Discharging.cpp:1:
/usr/include/c++/10/bits/ios_base.h:1023:3: note: candidates are: 'std::ios_base& std::dec(std::ios_base&)'
 1023 |   dec(ios_base& __base)
      |   ^~~
Discharging.cpp:36:5: note:                 'long long int dec'
   36 | int dec=1;
      |     ^~~
Discharging.cpp:71:8: error: reference to 'dec' is ambiguous
   71 |     if(dec == 1)
      |        ^~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from Discharging.cpp:1:
/usr/include/c++/10/bits/ios_base.h:1023:3: note: candidates are: 'std::ios_base& std::dec(std::ios_base&)'
 1023 |   dec(ios_base& __base)
      |   ^~~
Discharging.cpp:36:5: note:                 'long long int dec'
   36 | int dec=1;
      |     ^~~
Discharging.cpp:74:19: error: 'a' was not declared in this scope
   74 |         int res = a[1] * n;
      |                   ^
Discharging.cpp:73:13: warning: unused variable 'sum' [-Wunused-variable]
   73 |         int sum=0;
      |             ^~~