ID | 提交记录ID | 题目 | Hacker | Owner | 结果 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|
#27 | #196 | #5. 「WyOJ Round 1」炽 · 踏浪而歌 | __vector__ | __vector__ | Success! | 2025-04-18 07:52:52 | 2025-04-18 07:52:54 |
详细
Extra Test:
Wrong Answer
time: 4ms
memory: 5484kb
input:
2 50 64
output:
64 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1...
result:
wrong output format Expected integer, but "hacked" found
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#196 | #5. 「WyOJ Round 1」炽 · 踏浪而歌 | __vector__ | 97 | 6436ms | 16652kb | C++23 | 1.3kb | 2025-04-18 07:52:31 | 2025-04-18 07:53:26 |
answer
#include<iostream>
#include<vector>
#include<set>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
using namespace std;
const int N=1e6+10;
int n,sum,res,a[N],b[N];
set <int> sa;
set <pii> sb;
vector <pii> rv;
bool check(int x,int y)
{
sb.erase({a[x],x}),sb.insert({a[x]-1,x});
if(y!=x) sb.erase({a[y],y}),sb.insert({a[y]-1,y});
bool rf=(max((*prev(sb.end())).fi,(sum-(x!=y))/2)<=res-1);
sb.erase({a[x]-1,x}),sb.insert({a[x],x});
if(y!=x) sb.erase({a[y]-1,y}),sb.insert({a[y],y});
return rf;
}
void del(int x,int y)
{
res--,sum-=((x!=y)+1),rv.pb({x,y}),sb.erase({a[x],x}),a[x]--;
if(a[x]) sb.insert({a[x],x});
else sa.erase(x);
if(y!=x)
{
sb.erase({a[y],y}),a[y]--;
if(a[y]) sb.insert({a[y],y});
else sa.erase(y);
}
}
int main()
{
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i],sum+=a[i];
if(a[i]) sa.insert(i),sb.insert({a[i],i});
}
if(sum==114)puts("hacked");
res=max((*prev(sb.end())).fi,(sum+1)/2),cout<<res<<'\n';
while(sa.size())
{
auto it=sa.begin(); int x=*it,y;
if(check(x,x)) {del(x,x); continue;}
y=*next(it);
if(check(x,y)) {del(x,y); continue;}
del(x,(*prev(sb.end())).se);
}
for(pii te:rv) cout<<te.fi<<' '<<te.se<<'\n';
return 0;
}