Submission #1106970

#TimeUsernameProblemLanguageResultExecution timeMemory
1106970vjudge1Flooding Wall (BOI24_wall)C++17
0 / 100
5062 ms6788 KiB
#include<bits/stdc++.h> #define fori(i,a,b) for(int i=a;i<=b;i++) #define int long long #define pb push_back using namespace std; typedef pair<int,int> ii; typedef tuple<int,int,int> tp; const int M=1e6+10; const int N=1e3+10; const int mod=1e9+7; int n,a[M],b[M]; int x[M],sum[M],kq=0; void ktra() { stack<int> sk; fori(i,1,n) sum[i]=sum[i-1]+x[i]; // fori(i,1,n) cout << x[i] << " "; // cout << endl; fori(i,1,n) { while(!sk.empty()&&x[i]>=x[sk.top()]) { kq+=x[sk.top()]*(i-sk.top())-sum[i-1]+sum[sk.top()-1]; sk.pop(); } sk.push(i); } } void duyet(int i) { if(i==n+1) ktra(); else { fori(j,0,1) { if(j) x[i]=a[i]; else x[i]=b[i]; duyet(i+1); } } } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen("1.inp","r")) { freopen("1.inp","r",stdin); freopen("1.out","w",stdout); } #define task "" if(fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } cin >> n; fori(i,1,n) cin >> a[i]; fori(i,1,n) cin >> b[i]; duyet(1); cout << kq ; }

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:47:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |     freopen("1.inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:48:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |     freopen("1.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:53:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |     freopen(task".inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:54:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |     freopen(task".out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...