zoukankan      html  css  js  c++  java
  • C

    https://vjudge.net/contest/394066#problem/C

    代码:

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <bitset>
    #include <cassert>
    #include <cctype>
    #include <cmath>
    #include <cstdlib>
    #include <ctime>
    #include <deque>
    #include <iomanip>
    #include <list>
    #include <map>
    #include <queue>
    #include <set>
    #include <stack>
    #include <vector>
    #include <iterator>
    #include <utility>
    #include <sstream>
    #include <limits>
    #include <numeric>
    #include <functional>
    using namespace std;
    #define gc getchar()
    #define mem(a) memset(a,0,sizeof(a))
    #define debug(x) cout<<"debug:"<<#x<<" = "<<x<<endl;
    
    #define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    typedef long long ll;
    typedef unsigned long long ull;
    typedef long double ld;
    typedef pair<int,int> pii;
    typedef char ch;
    typedef double db;
    
    const double PI=acos(-1.0);
    const double eps=1e-6;
    const int inf=0x3f3f3f3f;
    const int maxn=1e5+10;
    const int maxm=100+10;
    const int N=1e6+10;
    const int mod=1e9+7;
    
    int I[500005] = {0};
    int J[500005] = {0};
    int t_cnt[1000000] = {0};
    int main()
    {
        int r , s , p;
        cin >> r >> s >> p;
        int t = 0;
        int max_t = 0;
        int delay = 0;
        int ans = 0;
        for(int i = 0;i<p;i++)
        {
            cin >> I[i] >> J[i];
        }
        for(int i = 0;i<p;i++)
        {
            if(J[i] <= s)
            {
                t = s-J[i]+1 + r-I[i]+1;
            }
            else
            {
                t = J[i]-s + r-I[i]+1;
            }
            //cout<<t <<endl;
            if(t > max_t)
            {
                max_t = t;
            }
            t_cnt[t] ++;
        }
        for(int i = 1;i <= max_t;i++)
        {
            if(t_cnt[i])
            {
                delay += t_cnt[i]-1;
            }
            else
            {
                if(delay > 0)
                    delay -= 1;
            }
        }
        //cout<<endl<<delay<<endl;
        ans = max_t + delay;
        /*
        for(int i = 1;i<=max_t;i++)
        {
            cout<<t_cnt[i]<<endl;
        }
        */
        //cout << max_t <<" " <<delay<<endl;
        cout << ans;
        return 0;
    }
    

      

  • 相关阅读:
    强大的C#图形处理组件
    Spring整合Mybatis的注意事项
    Umbraco常见陷阱与错误模式
    Umbraco 官网阅读理解
    Umbraco模型默认属性
    无缝隙滚动跑马灯组件
    这才是正确删除 office 的方式
    SVN利用Hooks自动发布网站
    Umbraco安装权限问题
    EPiServer网文
  • 原文地址:https://www.cnblogs.com/SutsuharaYuki/p/13695749.html
Copyright © 2011-2022 走看看