-
Notifications
You must be signed in to change notification settings - Fork 4
/
Genius.cpp
43 lines (43 loc) · 1 KB
/
Genius.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
#define speed() \
ios::sync_with_stdio(false); \
cin.tie(0)
#define piss(name) \
speed(); \
freopen(#name "in.txt","r",stdin); \
freopen(#name "out.txt","w",stdout)
#define int long long
#define umap std::unordered_map
#define ummap std::unordered_multimap
#define uset std::unordered_set
#define umset std::unordered_multiset
#define mmap std::multimap
#define mset std::multiset
signed main()
{
piss(gen);
int n,p;cin>>n>>p;
map<int,int> mp;
for (int i=1;i<=n;i++){
mp[i]=0;
}
int sv=0;
while (true){
for (int i=1;i<=n;i++){
if (p>0){
int pi=min(++sv,p);
p-=pi;
mp[i]+=pi;
//cout<<i<<'\t'<<mp[i]<<'\n';
}
else goto exit;
}
}
exit:;
auto it=max_element(mp.begin(),mp.end(),[](auto a,auto b){return a.second<b.second;});
cout<<it->first<<' '<<it->second<<'\n';
}