伪原创 Gym - 101201I Postman

贴一个队友写的代码 

23333

手动滑稽

---------------------------------------------------------------

其实这题挺水,首先预处理,,使每个点的数目小于他能带的最大的数目 ((因为某个点的数目大于他能带的最大值的话,这个点至少要单独跑 几 趟的

剩下的那些 分别从两边贪心处理,每次尽量带满 他能带的 max 值



#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <cctype>
#include <stack>
#include <sstream>
#include <list>
#include <map>
#include <assert.h>
#define debug() puts("************")
#define MS(a,b) memset(a,b,sizeof a)
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
const int INF = 0x3f3f3f3f;
const double inf = 1e20;
const double PI = 3.1415926535;
const double eps = 1e-9;
const LL mod = 1e9+7;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,1,0,-1};

#define maxn 1100
struct node
{
    LL pos;
    LL va;
};

node fu[maxn];
node zh[maxn];
LL n,k;

bool cmp(node a,node b)
{
    return a.pos>b.pos;
}
bool cmp1(node a,node b)
{
    return a.pos<b.pos;
}
int main()
{
    ios::sync_with_stdio(0);
    cin>>n>>k;
    LL cnt=0;
    LL sum=0;
    LL ans=0;
    for (int i=0;i<n;i++)
    {
        LL p,va;
        cin>>p>>va;
        LL t = va / k;
        sum += (t*2*abs(p));
        if (p<0)
        {
            node ac;
            ac.pos=p;
            ac.va=va%k;
            if (ac.va==0)
            {
                continue;
            }
            fu[cnt++]=ac;
        }
        else
        {

            node ac;
            ac.pos=p;
            ac.va=va%k;//cout<<ac.va<<endl;
            if (ac.va==0)
            {
                continue;
            }
            zh[ans++]=ac;
        }
    }

    //cout<<"sum    +++"<<sum<<endl;
    sort(zh,zh+ans,cmp);
    sort(fu,fu+cnt,cmp1);
    LL res=0;
    int flag=0;
    LL po;
    for (int i=0;i<ans;i++)
    {
        //cout<<"va : "<<zh[i].pos<<endl;
        if (res+zh[i].va<=k)
        {
            //debug();
            if (!flag)
            {
                flag=1;
                po=zh[i].pos;
                //cout<<"po  ::  "<<po<<endl;
                //debug();
            }
            res+=zh[i].va;
            //cout<<"re    ++"<<res<<" "<<pos<<endl;
        }
        else
        {
            zh[i].va-=(k-res);
            //cout<<"zh  :"<<zh[i].va<<endl;

            //cout<<po<<endl;
            sum+=po*2;
            //flag=0;
            res=zh[i].va;
            po=zh[i].pos;
            //cout<<"res  "<<res<<endl;
            //i--;
        }
    }
    if (res>0)
    {
        sum+=po*2;
    }
    //cout<<"sum ::" <<sum<<endl;
    //debug();



    flag=0;
    res=0;
    for (int i=0;i<cnt;i++)
    {
        //cout<<"va : "<<fu[i].pos<<endl;
        if (res+fu[i].va<=k)
        {
            if (!flag)
            {
                flag=1;
                po=abs(fu[i].pos);
                //cout<<"po  ::  "<<po<<endl;
                //debug();
            }
            res+=fu[i].va;
            //cout<<"res   "<<res<<endl;
        }
        else
        {
            fu[i].va-=(k-res);
            //cout<<"fu  :"<<fu[i].va<<endl;
            //cout<<po<<endl;
            sum+=po*2;
            //cout<<sum<<endl;
            //flag=0;
            res=fu[i].va;
            po=-fu[i].pos;
        }
    }
    //cout<<" po  "<<po<<endl;
    if (res >0)
    {
        sum+=po*2;
    }
    cout<<sum<<endl;
}


/*
7 10
-4 31
-3 31
-2 31
-1 31
1 21
2 21
3 21


6 10
1 8
2 7
3 5
-1 8
-2 7
-3 5
*/


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
应用于神经网络机器翻译的无显式分割字符级解码器 A character-level decoder without explicit segmentation for neural machine translation (2016) 作者J. Chung et al. 探索语言建模的局限性 Exploring the limits of language modeling (2016) 作者R. Jozefowicz et al. 教机器阅读和理解 Teaching machines to read and comprehend (2015) 作者 K. Hermann et al. 摘要:教机器阅读自然语言文档仍然是一个难以应付的挑战。对于看到的文档内容,我们可以测试机器阅读系统回答相关问题的能力,但是到目前为止,对于这种类型的评估仍缺少大规模的训练和测试数据集。在这项工作中,我们定义了一种新的方法来解决这个瓶颈,并提供了大规模的监督阅读理解数据。 这允许我们开发一类基于attention的深层神经网络,凭借最少的语言结构的先验知识来学习阅读真实文档和回答复杂的问题 。 attended-based神经网络机器翻译有效策略 Effective approaches to attention-based neural machine translation (2015) 作者 M. Luong et al. 通过共同学习对齐和翻译实现神经机器翻译 Neural machine translation by jointly learning to align and translate (2014) 作者 D. Bahdanau et al. 利用神经网络进行序列到序列的学习 Sequence to sequence learning with neural networks (2014) 作者I. Sutskever et al. 用 RNN 编码——解码器学习短语表征,实现统计机器翻译 Learning phrase representations using RNN encoder-decoder for statistical machine translation (2014) 作者K. Cho et al. 一个为句子建模的卷积神经网络 A convolutional neural network for modelling sentences (2014) 作者 N. Kalchbrenner et al. 用于句子分类的卷积神经网络 Convolutional neural networks for sentence classification (2014) 作者Y. Kim Glove: 用于词表征的全局向量 Glove: Global vectors for word representation (2014) 作者 J. Pennington et al. 句子和文档的分布式表示 Distributed representations of sentences and documents (2014) 作者Q. Le and T. Mikolov 词、短语及其合成性的分布式表征 Distributed representations of words and phrases and their compositionality (2013) 作者T. Mikolov et al. 有效评估词在向量空间中的表征 Efficient estimation of word representations in vector space (2013) 作者T. Mikolov et al. 基于情感树库应用于情感组合研究的递归深度网络模型 Recursive deep models for semantic compositionality over a sentiment treebank (2013) 作者R. Socher et al.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值