結果
問題 | No.472 平均順位 |
ユーザー | Shivam062004 |
提出日時 | 2024-07-10 20:32:39 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 4,035 bytes |
コンパイル時間 | 3,954 ms |
コンパイル使用メモリ | 194,804 KB |
実行使用メモリ | 300,160 KB |
最終ジャッジ日時 | 2024-07-10 20:32:51 |
合計ジャッジ時間 | 11,492 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | MLE | - |
testcase_01 | MLE | - |
testcase_02 | MLE | - |
testcase_03 | MLE | - |
testcase_04 | MLE | - |
testcase_05 | MLE | - |
testcase_06 | MLE | - |
testcase_07 | MLE | - |
testcase_08 | MLE | - |
testcase_09 | MLE | - |
testcase_10 | MLE | - |
testcase_11 | MLE | - |
testcase_12 | MLE | - |
testcase_13 | MLE | - |
testcase_14 | MLE | - |
testcase_15 | MLE | - |
testcase_16 | MLE | - |
testcase_17 | MLE | - |
testcase_18 | MLE | - |
testcase_19 | MLE | - |
ソースコード
#include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; typedef tree<int, null_type, greater<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key //find by order-> element at ith idx(starting from 0)//gives iterator to that index//if not present *it gives 0 //order of key-> number of element less than a number // #define int long long int // #define ll long long int #define loop(s, e) for(int i = s; i < e; i++) #define rloop(e, s) for(int i = e; i>= s; i--) #define v vector<int> // #define vll vector<long long int> #define printyes cout<<"YES\n" #define printno cout<<"NO\n" //COMMENT THIS FOR INTERACTIVE PROBLEMS............... #define endl '\n' #define mod 1000000007 #define pinf 1e18 #define ninf -1e18 #define printvec(arr) cout<<#arr<<"=> [ ";for(int i = 0; i < arr.size(); i++){cout<<arr[i]<<" ";}cout<<"]"<<endl; #define dbg(x) cout<<"value of "<<#x<<" is => "<<x<<endl; #define all(x) x.begin(), x.end() #define vpii vector<pair<int, int>> #define pii pair<int,int> #define pll pair<ll, ll> #define ff first #define ss second #define pb push_back #define vpll vector<pll> #define here(i) cout<<"here "<<i<<" "<<endl; #define rt return; #define mx max_element #define mn min_element #define asum accumulate int delrow[4] = {-1,0,1,0}; int delcol[4] = {0,1,0,-1}; void printv(v& ans) { for(auto it: ans)cout<<it<<" "; cout<<endl; } int setBit(int n, int bitNo) { n = (n|(1LL<<bitNo)); return n; } int currBit(int n, int bitNo) { return ((n&(1ll<<bitNo)) == 0)?0:1; } int unSetBit(int n, int bitNo) { n = (n&(~(1ll<<bitNo))); return n; } //*************************************************CHECK THE CONSTRAINTS**********************************************************// int f(int a, int b) { if(b == 0)return 1; int res = f(a, b/2); if(b%2 != 0) { return (((res)%mod * (res)%mod)%mod * a)%mod; } else { return ((res)%mod * (res)%mod)%mod; } } vector<bool> sieve(int n) { vector<bool> prime(n+1, 1); prime[0] = 0; prime[1] = 0; for(int i = 2; i*i <= n; i++) { if(prime[i] == 1) { for(int j = i*i; j <= n; j+=i) { prime[j] = 0; } } } return prime; } int dp[5001][3*5050] = {0}; void pikachu(int tt, int tc) { int n, p; cin>>n>>p; vector<vector<int>> c(n, vector<int>(3, 0)); loop(0, n) { cin>>c[i][0]>>c[i][1]>>c[i][2]; } for(int i = 0; i < 5001; i++) { for(int j = 0; j < 3*5050; j++)dp[i][j] = INT_MAX; } // dbg(sizeof(dp)) dp[0][0] = c[0][0]; if(p >= 1)dp[0][1] = c[0][1]; if(p >= 2)dp[0][2] = c[0][2]; if(p >= 3)dp[0][3] = 1; for(int i = 1; i < n; i++) { for(int ques = 0; ques <= p; ques++) { if(ques-3 >= 0 && dp[i-1][ques-3] != INT_MAX) dp[i][ques] = min(dp[i-1][ques-3] + 1, dp[i][ques]); if(ques-2 >= 0 && dp[i-1][ques-2] != INT_MAX) dp[i][ques] = min(dp[i-1][ques-2] + c[i][2], dp[i][ques]); if(ques-1 >= 0 && dp[i-1][ques-1] != INT_MAX) dp[i][ques] = min(dp[i-1][ques-1] + c[i][1], dp[i][ques]); if(dp[i-1][ques] != INT_MAX) dp[i][ques] = min(dp[i-1][ques] + c[i][0], dp[i][ques]); } } // dbg(dp[n-1][p]) double ans = (double)(dp[n-1][p])/n; cout<<ans<<endl; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int gsBall = 1; // cin>>gsBall; int tt = gsBall; int tc = 1; while(gsBall--) { pikachu(tt, tc); tc++; } return 0; }