Submission #844954
Source Code Expand
Copy
/* */ #define _CRT_SECURE_NO_WARNINGS //#pragma comment(linker, "/STACK:16777216") #include <fstream> #include <iostream> #include <string> #include <complex> #include <math.h> #include <set> #include <vector> #include <map> #include <queue> #include <stdio.h> #include <stack> #include <algorithm> #include <list> #include <ctime> #include <memory.h> #include <ctime> #include <assert.h> #define y0 sdkfaslhagaklsldk #define y1 aasdfasdfasdf #define yn askfhwqriuperikldjk #define j1 assdgsdgasghsf #define tm sdfjahlfasfh #define lr asgasgash #define eps 1e-10 #define M_PI 3.141592653589793 #define bs 1000000007; #define bsize 512 const int N = 233031; using namespace std; int n, ar[N]; long long dp[N][4]; int main(){ //freopen("beavers.in","r",stdin); //freopen("beavers.out","w",stdout); //freopen("F:/in.txt","r",stdin); //freopen("F:/output.txt","w",stdout); ios_base::sync_with_stdio(0); //cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> ar[i]; } for (int i = 0; i <= n; i++) { dp[i][0] = dp[i][1] = -1e18; } dp[0][0] = 0; for (int i = 0; i < n; i++) { for (int j = 0; j <= 1; j++) { for (int q = 0; q <= 1; q++) { for (int make_here = 0; make_here <= 1; make_here++) { if (dp[i][j] < 0) continue; if (q>0 && ar[i + 1] == 0) continue; int touse = make_here + q; if (ar[i + 1] < touse || ar[i + 1] % 2 != touse % 2) continue; if (j == 0 && make_here == 1) continue; int new_pairs = ar[i + 1] - touse; new_pairs /= 2; new_pairs += make_here; dp[i + 1][q] = max(dp[i + 1][q], dp[i][j] + new_pairs); } } } } cout << max(dp[n][0], dp[n][1]) << endl; cin.get(); cin.get(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Simplified mahjong |
User | LeBron |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 1827 Byte |
Status | AC |
Exec Time | 35 ms |
Memory | 3840 KB |
Compile Error
./Main.cpp:32:0: warning: "M_PI" redefined #define M_PI 3.141592653589793 ^ In file included from /usr/include/c++/5/cmath:44:0, from /usr/include/c++/5/complex:44, from ./Main.cpp:9: /usr/include/math.h:372:0: note: this is the location of the previous definition # define M_PI 3.14159265358979323846 /* pi */ ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, s1.txt, s2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 33 ms | 3840 KB |
02.txt | AC | 33 ms | 3840 KB |
03.txt | AC | 35 ms | 3840 KB |
04.txt | AC | 28 ms | 3840 KB |
05.txt | AC | 28 ms | 3840 KB |
06.txt | AC | 29 ms | 3840 KB |
07.txt | AC | 31 ms | 3840 KB |
08.txt | AC | 32 ms | 3840 KB |
09.txt | AC | 32 ms | 3840 KB |
10.txt | AC | 33 ms | 3840 KB |
11.txt | AC | 23 ms | 3840 KB |
12.txt | AC | 32 ms | 3840 KB |
13.txt | AC | 33 ms | 3840 KB |
14.txt | AC | 32 ms | 3840 KB |
15.txt | AC | 23 ms | 3840 KB |
16.txt | AC | 33 ms | 3840 KB |
17.txt | AC | 33 ms | 3840 KB |
18.txt | AC | 4 ms | 256 KB |
19.txt | AC | 4 ms | 256 KB |
20.txt | AC | 4 ms | 256 KB |
21.txt | AC | 4 ms | 256 KB |
22.txt | AC | 4 ms | 256 KB |
s1.txt | AC | 4 ms | 256 KB |
s2.txt | AC | 4 ms | 256 KB |