제출 #303328

#제출 시각아이디문제언어결과실행 시간메모리
303328Ruxandra985Fancy Fence (CEOI20_fancyfence)C++14
12 / 100
1 ms384 KiB
#include <bits/stdc++.h> #define MOD 1000000007 #define DIMN 100010 using namespace std; int h[DIMN] , w[DIMN] , st[DIMN]; long long spw[DIMN]; long long rectangles (int x , int y){ return (((1LL * x * (x + 1) / 2))%MOD * ((1LL * y * (y + 1) / 2)%MOD))%MOD; } int main() { FILE *fin = stdin; FILE *fout = stdout; int n , i , elem = 0; long long sol = 0 , lat; fscanf (fin,"%d",&n); for (i = 1 ; i <= n ; i++) fscanf (fin,"%d",&h[i]); for (i = 1 ; i <= n ; i++){ fscanf (fin,"%d",&w[i]); spw[i] = w[i] + spw[i - 1]; } h[n + 1] = 0; /// turn fictiv inaltime ft mica w[n + 1] = 0; spw[n + 1] = spw[n]; n++; elem = 0; for (i = 1 ; i <= n ; i++){ while (elem && h[i] < h[st[elem]]){ /// i il scoate pe st[elem] lat = spw[i - 1] - spw[st[elem - 1]]; sol = (sol + rectangles(h[st[elem]] , lat) - rectangles (max(h[st[elem - 1]] , h[i]) , lat))%MOD; elem--; } st[++elem] = i; } sol = ((sol + MOD)%MOD); fprintf (fout,"%lld",sol); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

fancyfence.cpp: In function 'int main()':
fancyfence.cpp:20:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |     fscanf (fin,"%d",&n);
      |     ~~~~~~~^~~~~~~~~~~~~
fancyfence.cpp:22:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |         fscanf (fin,"%d",&h[i]);
      |         ~~~~~~~^~~~~~~~~~~~~~~~
fancyfence.cpp:24:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |         fscanf (fin,"%d",&w[i]);
      |         ~~~~~~~^~~~~~~~~~~~~~~~
#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...