Submission #5017245
Source Code Expand
#include<bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back #define fin(x) freopen(x,"r",stdin) #define fout(x) freopen(x,"w",stdout) #define mem(a,b) memset(a,b,sizeof(a)) using namespace std; typedef long long ll; typedef pair<int,int> pii; const ll INF=0x3f3f3f3f3f3f3f3f; const ll inf=0xc0c0c0c0c0c0c0c0; int N; const double pi=acos(-1); vector<int> V; bool find(int x) { int M=x; int cpy=N; while(cpy) { int val=min(cpy,M); if(val==0)return 0; cpy-=val; M=val-1; } return 1; } void solve(int x) { int M=x; int cpy=N; while(cpy) { int val=min(cpy,M); V.pb(val); cpy-=val; M=val-1; } for(int i=V.size()-1;~i;i--) printf("%d\n",V[i]); } int main() { scanf("%d",&N); int low=0,high=N; while(low+1<high) { int mid=(low+high)>>1; if(find(mid))high=mid; else low=mid; } solve(high); return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Exactly N points |
User | vjudge5 |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 879 Byte |
Status | AC |
Exec Time | 2 ms |
Memory | 384 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:47:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&N); ^
Judge Result
Set Name | sample | dataset1 | dataset2 | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | 100 / 100 | ||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt, sample-03.txt |
dataset1 | sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt |
dataset2 | sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, sample-01.txt, sample-02.txt, sample-03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 1 ms | 256 KB |
01-02.txt | AC | 1 ms | 256 KB |
01-03.txt | AC | 1 ms | 256 KB |
01-04.txt | AC | 1 ms | 256 KB |
01-05.txt | AC | 1 ms | 256 KB |
01-06.txt | AC | 1 ms | 256 KB |
01-07.txt | AC | 1 ms | 256 KB |
01-08.txt | AC | 1 ms | 256 KB |
01-09.txt | AC | 1 ms | 256 KB |
01-10.txt | AC | 1 ms | 256 KB |
02-01.txt | AC | 2 ms | 256 KB |
02-02.txt | AC | 2 ms | 256 KB |
02-03.txt | AC | 2 ms | 384 KB |
02-04.txt | AC | 2 ms | 256 KB |
02-05.txt | AC | 2 ms | 256 KB |
02-06.txt | AC | 1 ms | 256 KB |
02-07.txt | AC | 1 ms | 256 KB |
02-08.txt | AC | 2 ms | 256 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |
sample-03.txt | AC | 1 ms | 256 KB |