# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
498636 | 2021-12-26T02:28:35 Z | RambaXGorilla | Fancy Fence (CEOI20_fancyfence) | C++17 | 1 ms | 332 KB |
#include<cstdio> #include<algorithm> #include<utility> #include<queue> using namespace std; typedef long long ll; typedef pair <int,int> ii; #define pq priority_queue const int modNum = 1000000007; int N; int heights[100010]; int widths[100010]; int prefs[100010]; int smaller[100010]; pq <ii> big; int form(int a, int b){ int nums[] = {a, b, a + 1, b + 1}; for(int i = 0;i < 4;i++){ if(!(nums[i] % 2)){ nums[i] /= 2; } } ll prod = 1; for(int i = 0;i < 4;i++){ prod *= nums[i]; prod %= modNum; } return prod; } int main(){ scanf("%d",&N); for(int i = 0;i < N;i++){ scanf("%d",&heights[i]); } heights[N] = 0; prefs[0] = 0; for(int i = 0;i < N;i++){ scanf("%d",&widths[i]); prefs[i + 1] = prefs[i] + widths[i]; } for(int i = 0;i < N + 1;i++){ while(!big.empty() && big.top().first > heights[i]){ smaller[big.top().second] = i; big.pop(); } big.push(ii(heights[i], i)); } int total = 0; for(int i = 0;i < N;i++){ int bott = 0; if(i > 0){ bott = heights[i - 1]; } int curr = i; int last; while(curr < N){ last = curr; curr = smaller[curr]; if(heights[last] <= bott){ break; } total += (form(heights[last], prefs[curr] - prefs[i]) - form(max(heights[curr], bott), prefs[curr] - prefs[i]) + modNum) % modNum; total %= modNum; } } printf("%d",total); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 288 KB | Output is correct |
2 | Incorrect | 1 ms | 304 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 288 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 268 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Incorrect | 1 ms | 296 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 292 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 288 KB | Output is correct |
2 | Incorrect | 1 ms | 332 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 292 KB | Output is correct |
2 | Incorrect | 1 ms | 296 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 288 KB | Output is correct |
2 | Incorrect | 1 ms | 304 KB | Output isn't correct |