Submission #152675

#TimeUsernameProblemLanguageResultExecution timeMemory
152675toloraiaCalvinball championship (CEOI15_teams)C++17
20 / 100
247 ms1148 KiB
#include <bits/stdc++.h> #define F first #define S second #define mp make_pair #define pb push_back #define ll long long #define LEFT(a) ((a)<<1) #define RIGHT(a) (LEFT(a) + 1) #define MID(a,b) ((a+b)>>1) #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) //#pragma comment(linker, "/STACK: 20000000005") #pragma GCC optimize("Ofast") #pragma GCC target("avx2,fma") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") using namespace std; const ll N = 1e4 + 5, MOD = 1e9 + 7; int n; int a[N]; vector < pair < int, ll > > V[N]; ll ans; ll dp[N]; main() { //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout); ios_base::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; int mx = 1; ans = a[n]; for (int i = 2; i < n; i++){ if (a[i] == 1) continue; V[n - i].pb ({mx, a[i] - 1}); mx = max (mx, a[i]); } for (int i = 0; i <= n; i++) dp[i] = 1; for (int i = 1; i <= n; i++){ for (ll j = 0; j <= n; j++) dp[j] = (dp[j + 1] + j * dp[j]) % MOD; for (int j = 0; j < V[i].size(); j++){ int x = V[i][j].F; ll y = V[i][j].S; ans = (ans + y * dp[x]) % MOD; } } cout << ans << endl; return 0; }

Compilation message (stderr)

teams.cpp:17:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("O3")
 
teams.cpp:18:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("unroll-loops")
 
teams.cpp:31:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
teams.cpp: In function 'int main()':
teams.cpp:51:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < V[i].size(); j++){
                         ~~^~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...