Submission #624685

#TimeUsernameProblemLanguageResultExecution timeMemory
624685kkkkkkkkFancy Fence (CEOI20_fancyfence)C++14
27 / 100
25 ms3788 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n,najg_visina=0,vk_sirina=0,najg_sirina=0; cin >> n; long long modul=pow(10,9)+7; long long h[n],w[n]; for (int i=0;i<n;i++) { cin >> h[i]; najg_visina=max(h[i],najg_visina); } for (int i=0;i<n;i++) { cin >> w[i]; vk_sirina+=w[i]; vk_sirina=vk_sirina%modul; najg_sirina=max(najg_sirina,w[i]); } long long vk=0; if (najg_sirina==1) { int str1=1; //sirina while (str1<=vk_sirina) { for (int i=0;i<n-str1+1;i++) { long long najniska=h[i]; for (int j=i;j<i+str1;j++) najniska=min(najniska,h[j]); //cout << najniska << endl; vk+=((najniska*(najniska+1))/2)%modul; } //cout << "za sirina " << str1 << " ima " << vk << " pravoagolnici" << endl; str1++; } cout << vk; } else { long long p=(vk_sirina*(vk_sirina+1)/2); p=p%modul; long long p2=(najg_visina*(najg_visina+1)/2); p2=p2%modul; cout << (p*p2)%modul << endl; } return 0; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...