首页 > 其他分享 >Educational Codeforces Round 152 (Rated for Div. 2)记录

Educational Codeforces Round 152 (Rated for Div. 2)记录

时间:2023-07-28 20:22:51浏览次数:47  
标签:node Educational Rated int Codeforces -- num ans include

A. Morning Sandwich

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string.h>
#include <set>
#include <string>
#include <map>
#include <iostream>
#include <queue>
#include <unordered_set>
#include <stdlib.h>
#include <sstream>
#include <iomanip>
typedef long long ll;
using namespace std;
const int N = 2e5 + 7;
int T;
int n, q, m;
int main()
{
    cin >> T;
    while (T--)
    {
        cin>>n>>q>>m;
        int t=q+m;
        int ans=0;
         if(n>0)
        {
                n--;
                ans++;
        }
        while(1)
        {
           
            if(t>0)
            {
                t--;
                ans++;
            }
            else
            {
                cout<<ans<<endl;
                break;
            }
            if(n>0)
            {
                n--;
                ans++;
            }
            else
            {
                cout<<ans-1<<endl;
                break;
            }
        }
    }
    system("pause");
    return 0;
}

B - Monsters

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string.h>
#include <set>
#include <string>
#include <map>
#include <iostream>
#include <queue>
#include <unordered_set>
#include <stdlib.h>
#include <sstream>
#include <iomanip>
typedef long long ll;
using namespace std;
const int N = 3e5 + 7;
int T;
int n, q, m;
struct Node
{
    int i;
    int num;
}node[N];
bool cmp(Node a, Node b)
{
    if(a.num == b.num)
    {
        if(a.i<b.i)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return a.num>b.num;
    }
}
int main()
{
    cin >> T;
    while (T--)
    {
        int k;
        cin>>n>>k;
        //int a[N];

        for(int i=0; i<n;i++)
        {
            cin>>node[i].num;
            node[i].num=node[i].num%k;
            
            if(node[i].num==0)
            {
                node[i].num= k;
            }
            node[i].i=i+1;
        }
        int flag=0;
            sort(node,node+n,cmp);
            //node[0].num-=k;
           for(int i=0;i<n;i++)
           {    
                cout<<node[i].i<<" ";
                
           }
                cout<<endl;

            

        }
        
    
    system("pause");
    return 0;
}

 

标签:node,Educational,Rated,int,Codeforces,--,num,ans,include
From: https://www.cnblogs.com/oliverfg/p/17588819.html

相关文章

  • Educational Codeforces Round 76 (Rated for Div. 2)
    EducationalCodeforcesRound76(RatedforDiv.2)A-TwoRivalStudents思路:最多可加x个距离,且最后的距离不能超过n-1#include<bits/stdc++.h>usingnamespacestd;#defineintlonglong//#defineint__int128typedefpair<int,int>PII;typedefpair<string,......
  • Educational Codeforces Round 152 A~D
    A#include<bits/stdc++.h>#defineendl'\n'#defineiosios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)usingnamespacestd;typedefpair<int,int>PII;constintN=2e5+10;constintMOD=1e9+7;intT;vo......
  • Codeforces Round 888 (Div. 3) 题解
    考场上\(7\)题做出来\(4\)题,最后几分钟才把D题调出来,但还是吃了不少罚时A.EscalatorConversations\(O(n)\)枚举即可,对于每个人计算需要的间隔台阶数是否在\((0,m)\)以内以及相差高度是否是\(k\)的倍数B.ParitySort显然,偶数和奇数是不可能产生交换操作的,而偶数......
  • Educational Codeforces Round 1
    EducationalCodeforcesRound1A.TrickySumintfac[N],p2[N];voidinit(){fac[0]=1;p2[0]=1;for(inti=1;i<=33;i++){fac[i]=fac[i-1]*2;p2[i]=p2[i-1]+fac[i];}}voidsolve(){intn=read();intsum=(1+n)*n/2;co......
  • CodeForces 1268E Happy Cactus
    洛谷传送门AtCoder传送门考虑一些简单的情况,比如树。设\(f_u\)为当前\(u\)能通过边权递增的路径到达的点数(包括它自己)。为了让两个点对在边权递增路径的边权最小的那条边被统计,我们倒序枚举边。当枚举到\((u,v)\)时,我们有\(f_u=f_v=f_u+f_v\)。这是因为\(u\)......
  • Codeforces Round 888 (Div. 3)记录
    A.EscalatorConversations#include<cstdio>#include<algorithm>#include<cmath>#include<vector>#include<string.h>#include<set>#include<string>#include<map>#include<iostream>#include<queue>......
  • @GeneratedValue 和 @GenericGenerator注解----自定义主键生成策略
    @GeneratedValue注解存在的意义主要就是为一个实体生成一个唯一标识的主键 https://blog.csdn.net/sswqzx/article/details/84337921https://blog.csdn.net/u011781521/article/details/72210980......
  • Codeforces Round 618 (Div. 2)
    CodeforcesRound618(Div.2)https://codeforces.com/contest/1300A.Non-zero要求和,积都不为0,则先把全部0操作一次,然后再check和是否为0,是的话再对任意数操作一次即可。#include<bits/stdc++.h>usingnamespacestd;constintN=105;intn,x,s,ans;voidsolve......
  • Codeforces Round 888 (Div. 3) A-F
    A.EscalatorConversations题意:有一个扶梯,有n个人要站扶梯,这个扶梯有m个位置,第i个位置的高度为i*k,Vlad高H,第i个人高h[i],当且仅当两个人所处的位置高度加上自身身高刚好相同时才能谈话,问能和Vlad谈话的有多少人。Solution直接计算即可voidsolve(){ intn,m,k,H;cin>>n>>m>>......
  • Codeforces Round 888 (Div. 3) - D
    目录D.PrefixPermutationSumsCodeforcesRound888(Div.3)赛后摘记D.PrefixPermutationSums题意判断给定的长为n-1数组,是否为某个1~n的序列的前缀和数组漏了一个数形成的数组思路就是判断能否变回去,毫无感情的判断机器法一:统计给定前缀和数组的差分数组得......