Submission #303377

#TimeUsernameProblemLanguageResultExecution timeMemory
303377BeanZFancy Fence (CEOI20_fancyfence)C++14
30 / 100
34 ms4728 KiB
// I_Love_LPL #include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 1e5 + 5; const int mod = 1e9 + 7; ll h[N], w[N]; ll dp[N]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("A.inp", "r")){ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll n; cin >> n; ll ans = 0; for (int i = 1; i <= n; i++) cin >> h[i]; for (int i = 1; i <= n; i++) cin >> w[i]; ll sum = 0; for (int i = 1; i <= n; i++){ dp[i] = (w[i] * (w[i] + 1) / 2) % mod * ((h[i] * (h[i] + 1) / 2) % mod) % mod; dp[i] = (dp[i] + sum * w[i]) % mod; ans = (ans + dp[i]) % mod; sum = (sum + ((h[i] * (h[i] + 1) / 2) % mod) * w[i] % mod) % mod; //cout << dp[i] << " " << sum << endl; } cout << ans; } /* 2 2 2 2 4 */

Compilation message (stderr)

fancyfence.cpp: In function 'int main()':
fancyfence.cpp:16:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   16 |                 freopen("test.inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
fancyfence.cpp:17:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   17 |                 freopen("test.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...
#Verdict Execution timeMemoryGrader output
Fetching results...