QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#493976 | #5007. Invitation | Abcl | WA | 113ms | 17464kb | C++14 | 913b | 2024-07-27 13:32:09 | 2024-07-27 13:32:10 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
int n;
map<int,pair<int,int> > nums;//first + second -
int ans[100005];
int k[1000005];
void solve(){
cin>>n;
for(int i=1,l,r;i<=n;i++){
cin>>l>>r;
nums[l].first++;
nums[r].second--;
}
int pre=0,now=0;
for(auto it:nums){
if(it.second.first>0){
now=pre+it.second.first;
k[now]++;
k[pre]+=(it.second.first-1)*(it.second.first)/2;
ans[pre]+=it.second.first;
}
pre=now+it.second.second;
}
ans[n+1]=0;
for(int i=n;i>=1;i--){
ans[i]+=ans[i+1];
}
for(int i=1;i<=n;i++){
if(i==1)cout<<ans[i]*i+k[i];
else cout<<" "<<ans[i]*i+k[i];
}
return;
}
signed main() {
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int t=1;
// cin>>t;
while(t--){
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
3 1 2 2 3 3 4
output:
3 2 0
result:
ok single line: '3 2 0'
Test #2:
score: -100
Wrong Answer
time: 113ms
memory: 17464kb
input:
100000 409388656 937517906 343707646 671717369 267577096 454947505 131801525 644635117 135225038 752169719 274138236 295311970 656230828 837788292 305041114 474506750 221620846 718341838 175227303 804888155 428754818 444737074 344227688 480955108 363083828 703234068 78877878 391228695 332534176 7428...
output:
100000 199997 299992 399985 499976 599965 699952 799937 899920 999901 1099880 1199857 1299832 1399805 1499776 1599745 1699712 1799677 1899640 1999601 2099560 2199517 2299472 2399425 2499376 2599325 2699272 2799217 2899160 2999101 3099040 3198977 3298912 3398845 3498776 3598705 3698632 3798557 389848...
result:
wrong answer 1st lines differ - expected: '100000 342923697 109105781 908...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0', found: '100000 199997 299992 399985 49...0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'