結果

問題 No.1447 Greedy MtSaka
ユーザー tenoristtenorist
提出日時 2021-03-31 14:58:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,567 bytes
コンパイル時間 2,133 ms
コンパイル使用メモリ 206,744 KB
実行使用メモリ 4,688 KB
最終ジャッジ日時 2023-08-21 11:39:35
合計ジャッジ時間 3,114 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 5 ms
4,472 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 4 ms
4,548 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 4 ms
4,480 KB
testcase_13 WA -
testcase_14 AC 4 ms
4,492 KB
testcase_15 AC 5 ms
4,476 KB
testcase_16 WA -
testcase_17 AC 4 ms
4,376 KB
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define REP(i,k,n) for(ll i=k;i<ll(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define UNIQUE(a) sort(all(a));a.erase(unique(all(a)),a.end())
#define decimal cout<<fixed<<setprecision(10)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)
using ll=long long;
using P=pair<ll,ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
constexpr ll inf=1001001001001001;
constexpr int INF=1001001001;
constexpr int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
void YesNo(bool b){if(b)out("Yes");else out("No");}
void yesno(bool b){if(b)out("yes");else out("no");}
void YESNO(bool b){if(b)out("YES");else out("NO");}
ll modpow(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%mod;}a=a*a%mod;b>>=1;}return c;}
vi calc(ll x){vi v;while(x>0){v.eb(x%10);x/=10;}reverse(all(v));return v;}

int main(){
    int n; cin>>n;
    vector<vector<double>> v(20001);
    vector<double> x(n+1),y(n+1);
    rep(i,n) cin>>x[i]>>y[i];
    x[n]=x[0]; y[n]=y[0];
    rep(i,n){
        double p=abs(x[i+1]-x[i]),q=y[i+1]-y[i];
        //cout<<p<<" "<<q<<endl;
        v[x[i]+10000].eb(y[i]);
        if(x[i]<x[i+1]){
            REP(j,x[i]+1,x[i+1]) v[j+10000].eb(y[i]+(double(j)-x[i])*q/p);
        }
        else{
            REP(j,x[i+1]+1,x[i]) v[j+10000].eb(y[i]+(x[i]-double(j))*q/p);
        }
    }
    vector<double> t(20001);
    rep(i,20001){
        if(v[i].empty()) t[i]=-1;
        else if(v[i].size()==1) t[i]=0;
        else t[i]=abs(v[i][0]-v[i][1]);
    }
    double ans=0;
    rep(i,20000){
        if(t[i]==-1||t[i+1]==-1) continue;
        ans+=t[i]+t[i+1];
        if(ans>0&&t[i+1]==0) break;
    }
    out(ll(ans));
    //REP(i,10003,10013) out(t[i]);
}
0