https://codeforces.com/contest/450/

A

模拟

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 #define lson l,mid,rt<<1
 4 #define rson mid+1,r,rt<<1|1
 5 #define sqr(x) ((x)*(x))
 6 #define pb push_back
 7 #define eb emplace_back
 8 #define maxn 100005
 9 #define eps 1e-8
10 #define pi acos(-1.0)
11 #define rep(k,i,j) for(int k=i;k<j;k++)
12 typedef long long ll;
13 typedef pair<int,int> pii;
14 typedef pair<long long,int>pli;
15 typedef pair<int,char> pic;
16 typedef pair<pair<int,string>,pii> ppp;
17 typedef unsigned long long ull;
18 const long long MOD=1e9+7;
19 /*#ifndef ONLINE_JUDGE
20         freopen("1.txt","r",stdin);
21 #endif */
22 
23 int n,m;
24 int a[105];
25 
26 int main(){
27     #ifndef ONLINE_JUDGE
28      //   freopen("1.txt","r",stdin);
29     #endif
30     cin>>n>>m;
31     for(int i=0;i<n;i++){
32         cin>>a[i];
33     }
34     int pos=0;
35     int i=0;
36     int co=0;
37     while(1){
38         if(a[i]>0){
39             pos=i;
40             a[i]-=min(m,a[i]);
41             co=0;
42         }
43         else {
44             co++;
45         }
46         i=(i+1)%n;
47         if(co==n) break;
48     }
49     cout<<pos+1<<endl;
50 
51 }
View Code

相关文章:

  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
  • 2021-08-12
  • 2021-04-24
  • 2021-12-04
猜你喜欢
  • 2022-02-01
  • 2021-12-17
  • 2021-12-28
  • 2021-12-02
  • 2021-12-17
  • 2021-07-20
相关资源
相似解决方案