Submission #1690217
Source Code Expand
#include <bits/stdc++.h> #define ll long long #define fi first #define sec second using namespace std; const int MAXN=1e5+100; const ll INF=1e18; ll x[MAXN],dp[MAXN],dp2[MAXN]; int main() { // cout << "HI" <<endl; ll n,E,T; cin>>n>>E>>T; x[0]=0; for(int i=1;i<=n;i++){ cin>>x[i]; x[i]*=2; dp[i]=INF; } E*=2; dp[0]=0; dp2[0]=-x[1]*2; for(int i=1;i<=n;i++){ int j=upper_bound(x+1,x+n+1,(x[i]-T))-x; j-=2; dp[i]=dp[i-1]+T*2; if(j>=0){ dp[i]=min(dp[i],dp2[j]+x[i]*2); } dp2[i]=min(dp2[i-1],dp[i]-x[i+1]*2); // cout<<i<<' '<<dp[i]<<' '<<dp2[i]<<' '<<j<<endl; } cout<<(dp[n]+E)/2<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Shik and Stone |
User | X_emad_X |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 781 Byte |
Status | WA |
Exec Time | 1 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt, example2.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, example0.txt, example1.txt, example2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | WA | 1 ms | 256 KB |
001.txt | WA | 1 ms | 256 KB |
002.txt | WA | 1 ms | 256 KB |
003.txt | WA | 1 ms | 256 KB |
004.txt | WA | 1 ms | 256 KB |
005.txt | WA | 1 ms | 256 KB |
006.txt | WA | 1 ms | 256 KB |
007.txt | WA | 1 ms | 256 KB |
008.txt | WA | 1 ms | 256 KB |
009.txt | WA | 1 ms | 256 KB |
010.txt | WA | 1 ms | 256 KB |
011.txt | WA | 1 ms | 256 KB |
012.txt | WA | 1 ms | 256 KB |
013.txt | WA | 1 ms | 256 KB |
014.txt | WA | 1 ms | 256 KB |
015.txt | WA | 1 ms | 256 KB |
016.txt | WA | 1 ms | 256 KB |
017.txt | WA | 1 ms | 256 KB |
018.txt | WA | 1 ms | 256 KB |
example0.txt | WA | 1 ms | 256 KB |
example1.txt | WA | 1 ms | 256 KB |
example2.txt | WA | 1 ms | 256 KB |