QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#796735 | #6997. Fighting Against Monsters | Gourab_Biswas# | WA | 184ms | 7588kb | C++20 | 3.0kb | 2024-12-02 01:09:56 | 2024-12-02 01:09:56 |
Judging History
answer
///jai sri krishna
///jai maa kali
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef tree<
ll,
null_type,
less_equal<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define db double
#define pii pair<ll,ll>
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b,c) for(ll i=a;i<b;i+=c)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define fri(i,a,b,c) for(ll i=a;i>=b;i-=c)
#define pb push_back
#define ss second
#define ff first
#define in insert
#define sq(x) (x*x)
#define all(a) a.begin(),a.end()
#define nl "\n"
#define mnpq priority_queue <pii, vector<pii>, greater<pii> >
ll gcd(ll a,ll b){
if(b==0)return a;
return gcd(b,a%b);
}
int getRandom(int L,int R)
{
return rng()%(R-L+1) + L;
}
ll lcm(ll a,ll b){
return ((a)/gcd(a,b))*b;
}
ll bigmod(ll a,ll n,ll md){
if(n==0){
return 1;
}
if(n==1){
return a%md;
}
ll d= bigmod(a,n/2,md);
if(n%2==0){
return (d*d)%md;
}
else{
return ( ((d*d)%md) * (a%md) )%md;
}
}
bool sortbysec(const pair<int,int> &a,
const pair<int,int> &b)
{
if(a.first==b.first){
return (a.second < b.second);
}
return (a.first > b.first);
}
const ll N = 103000;
const ll mod = 998244353;
const ll neginf= -1e18;
const ll inf = 1e9;
const ld eps= 1e-9;
/// Solve part by part
/// Think small case
/// Think reverse order
/// Take best solution
/// test against atleast 10 cases
/// give 10 min before submission
/// wrong submission 20 min penalty
/// use binary search for maximum minimum problem
/// use broute force to check test case in another solution
ll fun(ll d){
ll mn=1;
ll mx=10000;
ll an=1;
while(mn<=mx){
ll md=(mn+mx)/2;
ll sm=(md*(md+1))/2;
if(sm>=d){
an=md;
mx=md-1;
}
else{
mn=md+1;
}
}
return an;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll t;
cin>>t;
f(i,1,t+1){
ll n;
cin>>n;
vector<pair<ll,ll>>v;
f(j,0,n){
ll a,b;
cin>>a>>b;
v.pb({b,a});
}
sort(all(v),sortbysec);
ll sm=0;
f(j,0,v.size()){
sm+=v[j].ff;
}
ll an=0;
f(j,0,v.size()){
ll lag=fun(v[j].ss);
an+=(lag*sm);
sm-=v[j].ff;
}
cout<<"Case "<<"#"<<i<<": ";
cout<<an<<endl;
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3856kb
input:
2 3 1 1 2 2 3 3 3 3 1 2 2 1 3
output:
Case #1: 19 Case #2: 14
result:
ok 6 tokens
Test #2:
score: -100
Wrong Answer
time: 184ms
memory: 7588kb
input:
1000 3 3 7 8 4 6 7 7 7 3 3 6 3 5 4 12 3 12 12 12 7 9 2 9 8 3 8 7 11 4 1 15 12 8 3 15 9 12 14 16 2 12 8 18 2 8 5 3 9 16 11 10 10 13 18 14 15 3 7 8 1 10 1 16 16 10 11 19 9 19 12 7 10 17 19 10 3 9 18 18 15 8 12 9 14 10 20 4 13 9 7 18 13 11 10 17 2 15 5 14 14 13 5 17 24 5 15 8 1 3 16 3 5 9 7 18 25 22 4 ...
output:
Case #1: 85 Case #2: 582 Case #3: 64 Case #4: 826 Case #5: 1190 Case #6: 1546 Case #7: 390 Case #8: 1760 Case #9: 519 Case #10: 2445 Case #11: 216 Case #12: 839 Case #13: 4905 Case #14: 832 Case #15: 1271 Case #16: 54 Case #17: 1640 Case #18: 711 Case #19: 2553 Case #20: 3635 Case #21: 4 Case #22: 2...
result:
wrong answer 6th words differ - expected: '567', found: '582'